Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
MozABConduitGenCond.cpp File Reference
#include <malloc.h>
#include <CPalmRec.cpp>
#include <CPString.cpp>
#include <CPCatgry.cpp>
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include <memory.h>
#include <sys/stat.h>
#include <TCHAR.H>
#include <COMMCTRL.H>
#include <syncmgr.h>
#include "MozABConduitGenCond.h"
#include "resource.h"
#include <logstrng.h>
#include <PALM_CMN.H>
#include "MozABConduitSync.h"

Go to the source code of this file.

Defines

#define STRICT   1
#define ASSERT(f)   ((void)0)
#define TRACE0(sz)
#define TRACE(sz)
#define CONDUIT_NAME   "MozABConduit"

Functions

long CALLBACK CondCfgDlgProc (HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
void LdCfgDlgBmps (HWND hDlg)
int APIENTRY DllMain (HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
ExportFunc long OpenConduit (PROGRESSFN pFn, CSyncProperties &rProps)
ExportFunc long GetConduitName (char *pszName, WORD nLen)
ExportFunc DWORD GetConduitVersion ()
ExportFunc long ConfigureConduit (CSyncPreference &pref)
ExportFunc long GetConduitInfo (ConduitInfoEnum infoType, void *pInArgs, void *pOut, DWORD *pdwOutSize)

Variables

HANDLE hLangInstance
HANDLE hAppInstance
static int iTerminationCount = 0
DWORD tId = 0

Define Documentation

#define ASSERT (   f)    ((void)0)

Definition at line 7 of file MozABConduitGenCond.cpp.

#define CONDUIT_NAME   "MozABConduit"

Definition at line 39 of file MozABConduitGenCond.cpp.

#define STRICT   1

Definition at line 6 of file MozABConduitGenCond.cpp.

#define TRACE (   sz)

Definition at line 9 of file MozABConduitGenCond.cpp.

#define TRACE0 (   sz)

Definition at line 8 of file MozABConduitGenCond.cpp.


Function Documentation

long CALLBACK CondCfgDlgProc ( HWND  hWnd,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 318 of file MozABConduitGenCond.cpp.

{
    static CfgConduitInfoType *pCfgInfo;
    TCHAR szPath[256];

    switch (Message) 
       {
      case WM_INITDIALOG:

        if (lParam != 0) {
          TCHAR szBuffer[256];
          TCHAR szBuf2[256];
          LoadString((HINSTANCE)hLangInstance, IDS_SYNC_ACTION_TEXT, szBuffer, 
                     sizeof(szBuffer));
          SetDlgItemText(hWnd, IDC_ACTIONGROUPBOXTEXT, szBuffer);

          LoadString((HINSTANCE)hLangInstance, IDS_CONDUIT_NAME, szBuffer, 
                     sizeof(szBuffer));
          SetWindowText(hWnd, szBuffer);
     
          // Load the bitmaps properly
          LdCfgDlgBmps(hWnd);

          pCfgInfo = (CfgConduitInfoType *)lParam;
          switch (pCfgInfo->syncTemporary)
                {
            case eFast:
            case eSlow:
              CheckRadioButton(hWnd, IDC_RADIO_SYNC, IDC_RADIO_DONOTHING, 
                               IDC_RADIO_SYNC);
              LoadString((HINSTANCE)hLangInstance, IDS_SYNC_FILES, szBuffer, 
                         sizeof(szBuffer));
              break;
            case ePCtoHH:
              CheckRadioButton( hWnd, IDC_RADIO_SYNC, IDC_RADIO_DONOTHING, IDC_RADIO_PCTOHH);
              LoadString((HINSTANCE)hLangInstance, IDS_PCTOHH, szBuffer, sizeof(szBuffer));
              break;
            case eHHtoPC:
              CheckRadioButton( hWnd, IDC_RADIO_SYNC, IDC_RADIO_DONOTHING, IDC_RADIO_HHTOPC);
              LoadString((HINSTANCE)hLangInstance, IDS_HHTOPC, szBuffer, sizeof(szBuffer));
              break;
            case eDoNothing:
            default:
              CheckRadioButton(hWnd, IDC_RADIO_SYNC, IDC_RADIO_DONOTHING, 
                               IDC_RADIO_DONOTHING);
              LoadString((HINSTANCE)hLangInstance, IDS_DO_NOTHING, szBuffer,
                         sizeof(szBuffer));
              break;
          }
          // did we get called from the old config call or the new cfg call?
          if (pCfgInfo->dwCreatorId != 0) 
                {
            SetDlgItemText(hWnd, IDC_STATIC_TEMPORARY, szBuffer);

            switch (pCfgInfo->syncPermanent)
                     {
              case eFast:
              case eSlow:
                LoadString((HINSTANCE)hLangInstance, IDS_SYNC_FILES, szBuffer,
                           sizeof(szBuffer));
                break;
              case ePCtoHH:
                LoadString((HINSTANCE)hLangInstance, IDS_PCTOHH, szBuffer,
                           sizeof(szBuffer));
                break;

              case eHHtoPC:
                LoadString((HINSTANCE)hLangInstance, IDS_HHTOPC, szBuffer,
                           sizeof(szBuffer));
                break;
              case eDoNothing:
              default:
                LoadString((HINSTANCE)hLangInstance, IDS_DO_NOTHING, szBuffer,
                           sizeof(szBuffer));
                break;
            }
            SetDlgItemText(hWnd, IDC_STATIC_PERMANENT, szBuffer);

            LoadString((HINSTANCE)hLangInstance, IDS_CURRENT_SETTINGS_GROUP, 
                       szBuffer, sizeof(szBuffer));
            wsprintf(szBuf2, szBuffer, pCfgInfo->szUser);
            SetDlgItemText(hWnd, IDC_CURRENT_SETTINGS_GROUP, szBuf2);
          }
        }
        break;
      case WM_COMMAND:
        switch (wParam) 
              {
          case IDC_RADIO_SYNC:
          case IDC_RADIO_DONOTHING:
          case IDC_RADIO_HHTOPC:
          case IDC_RADIO_PCTOHH:
            CheckRadioButton( hWnd, IDC_RADIO_SYNC, IDC_RADIO_DONOTHING, wParam);
            break;
          case IDCANCEL:
            EndDialog(hWnd, 1);
            return TRUE;
          case IDOK:
            if (IsDlgButtonChecked(hWnd, IDC_RADIO_SYNC)) 
                pCfgInfo->syncNew = eFast;
            else if (IsDlgButtonChecked(hWnd, IDC_RADIO_PCTOHH)) 
                pCfgInfo->syncNew = ePCtoHH;
            else if (IsDlgButtonChecked(hWnd, IDC_RADIO_HHTOPC))
                pCfgInfo->syncNew = eHHtoPC;
            else
                pCfgInfo->syncNew = eDoNothing;
            pCfgInfo->syncPref = (IsDlgButtonChecked(hWnd, IDC_MAKEDEFAULT))
                            ?  ePermanentPreference : eTemporaryPreference;
            EndDialog(hWnd, 0);
            return TRUE;
          default:
            break;
        }
        break;

      case WM_SYSCOLORCHANGE:
        LdCfgDlgBmps(hWnd);
        break;

      default:
        break;
    }
    return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ExportFunc long ConfigureConduit ( CSyncPreference &  pref)

Definition at line 204 of file MozABConduitGenCond.cpp.

{

    long nRtn = -1;
    CfgConduitInfoType cfgcond;
    cfgcond.dwVersion = CFGCONDUITINFO_VERSION_1;
    cfgcond.dwSize  = sizeof(CfgConduitInfoType);
    cfgcond.dwCreatorId = 0;
    cfgcond.dwUserId = 0;
    memset(cfgcond.szUser , 0, sizeof(cfgcond.szUser));
    memset(cfgcond.m_PathName, 0, sizeof(cfgcond.m_PathName)); 
    cfgcond.syncPermanent = pref.m_SyncType;
    cfgcond.syncTemporary = pref.m_SyncType;
    cfgcond.syncNew = pref.m_SyncType;
    cfgcond.syncPref = eTemporaryPreference; 

    int irv;
    irv = DialogBoxParam((HINSTANCE)hLangInstance, 
              MAKEINTRESOURCE(IDD_CONDUIT_ACTION), 
              GetForegroundWindow(), 
              (DLGPROC)CondCfgDlgProc,
              (LPARAM)&cfgcond);
    if (irv == 0) 
       {
        pref.m_SyncType = cfgcond.syncNew;
        pref.m_SyncPref = cfgcond.syncPref;
        nRtn = 0;
    }

    return nRtn;
}

Here is the call graph for this function:

int APIENTRY DllMain ( HINSTANCE  hInstance,
DWORD  dwReason,
LPVOID  lpReserved 
)

Definition at line 74 of file MozABConduitGenCond.cpp.

{


    if (dwReason == DLL_PROCESS_ATTACH)
    {
        TRACE0("EXPORTED FUNCTIONS Initializing!\n");
        
        if (!iTerminationCount ) {
            hAppInstance = hInstance;
            // use PalmLoadLanguage here to load different languages
            hLangInstance = hInstance;
        }
        ++iTerminationCount;

        tId = TlsAlloc();
        if (tId == 0xFFFFFFFF)
            return FALSE;
    }
    else if (dwReason == DLL_PROCESS_DETACH)
    {
        TRACE0("EXPORTED FUNCTIONS Terminating!\n");

        --iTerminationCount;
        if (!iTerminationCount ) {
            // use PalmFreeLanguage here to unload different languages
        }
        TlsFree(tId);
    }
    return 1;   // ok
}
ExportFunc long GetConduitInfo ( ConduitInfoEnum  infoType,
void pInArgs,
void pOut,
DWORD pdwOutSize 
)

Definition at line 277 of file MozABConduitGenCond.cpp.

{
    if (!pOut)
        return CONDERR_INVALID_PTR;
    if (!pdwOutSize)
        return CONDERR_INVALID_OUTSIZE_PTR;

    switch (infoType) 
       {
        case eConduitName:

            // This code is for example. This conduit does not use this code
            
            if (!pInArgs)
                return CONDERR_INVALID_INARGS_PTR;
            ConduitRequestInfoType *pInfo;
            pInfo = (ConduitRequestInfoType *)pInArgs;
            if ((pInfo->dwVersion != CONDUITREQUESTINFO_VERSION_1) ||
                (pInfo->dwSize != SZ_CONDUITREQUESTINFO))
                return CONDERR_INVALID_INARGS_STRUCT;
           
                pOut = CONDUIT_NAME;
                return CONDERR_CONDUIT_RESOURCE_FAILURE;
            break;
        case eDefaultAction:
            if (*pdwOutSize != sizeof(eSyncTypes))
                return CONDERR_INVALID_BUFFER_SIZE;
            (*(eSyncTypes*)pOut) = eFast;
            break;
        case eMfcVersion:
            if (*pdwOutSize != sizeof(DWORD))
                return CONDERR_INVALID_BUFFER_SIZE;
            (*(DWORD*)pOut) = MFC_NOT_USED;
            break;
        default:
            return CONDERR_UNSUPPORTED_CONDUITINFO_ENUM;
    }
    return 0;
}
ExportFunc long GetConduitName ( char *  pszName,
WORD  nLen 
)

Definition at line 159 of file MozABConduitGenCond.cpp.

{
    strncpy(pszName,CONDUIT_NAME, nLen-1);   
    *(pszName+nLen-1) = '\0';

    return 0;
}

Here is the caller graph for this function:

Definition at line 184 of file MozABConduitGenCond.cpp.

void LdCfgDlgBmps ( HWND  hDlg)

Definition at line 443 of file MozABConduitGenCond.cpp.

{
  COLORMAP    cMap;
  HWND        hwndButton;
  HBITMAP     hBmp, hOldBmp;

  //
  // setup the bitmaps
  //
  cMap.to = GetSysColor(COLOR_BTNFACE);
  cMap.from = RGB(192,192,192);

  // Sync 
  hBmp = CreateMappedBitmap((HINSTANCE)hLangInstance, IDB_SYNC, 0, &cMap, 1);
  // associate the bitmap with the button.
  if ((hwndButton = GetDlgItem(hDlg, IDC_SYNC)) != NULL)
  {
    hOldBmp = (HBITMAP)SendMessage(hwndButton, STM_SETIMAGE,
                                   (WPARAM)IMAGE_BITMAP, (LPARAM)(HANDLE)hBmp);
    if (hOldBmp != NULL)
      DeleteObject((HGDIOBJ)hOldBmp);
  }

  // Do Nothing 
  hBmp = CreateMappedBitmap((HINSTANCE)hLangInstance, IDB_DONOTHING, 0, &cMap, 1);
  // associate the bitmap with the button.
  if ((hwndButton = GetDlgItem(hDlg, IDC_DONOTHING)) != NULL)
  {
    hOldBmp = (HBITMAP)SendMessage(hwndButton, STM_SETIMAGE,
                                   (WPARAM)IMAGE_BITMAP, (LPARAM)(HANDLE)hBmp);
    if (hOldBmp != NULL)
      DeleteObject((HGDIOBJ)hOldBmp);
  }
  hBmp = CreateMappedBitmap((HINSTANCE)hLangInstance, IDB_PCTOHH, 0, &cMap, 1);
  // associate the bitmap with the button.
  if ((hwndButton = GetDlgItem(hDlg, IDC_PCTOHH)) != NULL)
  {
    hOldBmp = (HBITMAP)SendMessage(hwndButton, STM_SETIMAGE,
                                   (WPARAM)IMAGE_BITMAP, (LPARAM)(HANDLE)hBmp);
    if (hOldBmp != NULL)
      DeleteObject((HGDIOBJ)hOldBmp);
  }
  hBmp = CreateMappedBitmap((HINSTANCE)hLangInstance, IDB_HHTOPC, 0, &cMap, 1);
  // associate the bitmap with the button.
  if ((hwndButton = GetDlgItem(hDlg, IDC_HHTOPC)) != NULL)
  {
    hOldBmp = (HBITMAP)SendMessage(hwndButton, STM_SETIMAGE,
                                   (WPARAM)IMAGE_BITMAP, (LPARAM)(HANDLE)hBmp);
    if (hOldBmp != NULL)
      DeleteObject((HGDIOBJ)hOldBmp);
  }
}

Here is the caller graph for this function:

ExportFunc long OpenConduit ( PROGRESSFN  pFn,
CSyncProperties &  rProps 
)

Definition at line 126 of file MozABConduitGenCond.cpp.

{
    long retval = -1;
    if (pFn)
    {
       CMozABConduitSync * pABSync = new CMozABConduitSync(rProps);
        if (pABSync)
              {
            retval = pABSync->Perform();
            delete pABSync;
        }
    }
    return(retval);
}

Here is the call graph for this function:


Variable Documentation

Definition at line 43 of file MozABConduitGenCond.cpp.

Definition at line 42 of file MozABConduitGenCond.cpp.

int iTerminationCount = 0 [static]

Definition at line 68 of file MozABConduitGenCond.cpp.

DWORD tId = 0

Definition at line 70 of file MozABConduitGenCond.cpp.