DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Header

Untracked file

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494
/***************************************************************************
 *
 * EXPORTED FUNCTIONS Conduit Entry Points Source File
 *
 **************************************************************************/
#define STRICT 1
#define ASSERT(f)          ((void)0)
#define TRACE0(sz)
#define TRACE(sz)

#include <malloc.h>


#include <CPalmRec.cpp>
#include <CPString.cpp>
#include <CPCatgry.cpp>

#include <windows.h>
#include <string.h>
#include <stdio.h>
#ifdef METROWERKS_WIN
#include <wmem.h>
#else
#include <memory.h>
#endif
#include <sys/stat.h>
#include <TCHAR.H>
#include <COMMCTRL.H>

#include <syncmgr.h>
#include "MozABConduitGenCond.h"
#include "resource.h"

#include <logstrng.h>

// TODO - Include custom sync header

#include <PALM_CMN.H>
#define CONDUIT_NAME "MozABConduit"
#include "MozABConduitSync.h"

HANDLE hLangInstance;
HANDLE hAppInstance;
extern HANDLE hLangInstance;
extern HANDLE hAppInstance;

long CALLBACK CondCfgDlgProc(HWND hWnd, UINT Message, WPARAM wParam, 
                             LPARAM lParam);
void LdCfgDlgBmps(HWND hDlg);

/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
//
//     Function:        DllMain()
//
//     Description:    main entry point to the MozABConduitProto component
//
//     Parameters:    hInstance - instance handle of the DLL
//                    dwReason  - why the entry point was called
//                    lpReserved - reserved
//
//     Returns:        1 if okay
//
/////////////////////////////////////////////////////////////////////////////
#ifndef _68K_

static int iTerminationCount = 0;

DWORD tId = 0;


extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{


    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
}
#endif


/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
//
//     Function:        OpenConduit()
//
//     Description:  Extern "C" entry point into this conduit which starts 
//                   the process of synchronizing the local database table 
//                   with a remote conterpart residing on the remote view 
//                   device. 
//
//     Parameters:   Pointer to a callback function used to report progress.
//                    
//                
//
//     Returns:        
//
/////////////////////////////////////////////////////////////////////////////
ExportFunc long OpenConduit(PROGRESSFN pFn, CSyncProperties& rProps)
{
    long retval = -1;
    if (pFn)
    {
       CMozABConduitSync * pABSync = new CMozABConduitSync(rProps);
        if (pABSync)
		{
            retval = pABSync->Perform();
            delete pABSync;
        }
    }
    return(retval);
}

/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
//
//       Function:              GetConduitName()
//
//       Description:  Extern "C" entry point into this conduit which returns
//                                the name to be used when display messages 
//                                regarding this conduit.
//
//       Parameters:   pszName - buffer in which to place the name
//                                 nLen - maximum number of bytes of buffer     
//                                      
//                              
//
//       Returns:          -1 indicates erros
//
/////////////////////////////////////////////////////////////////////////////
ExportFunc long GetConduitName(char* pszName,WORD nLen)
{
    strncpy(pszName,CONDUIT_NAME, nLen-1);   
    *(pszName+nLen-1) = '\0';

    return 0;
}

/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
//
//       Function:     GetConduitVersion()
//
//       Description:  Extern "C" entry point into this conduit which returns
//                     the conduits version
//
//       Parameters:   none
//
//       Returns:      DWORD indicating major and minor version number
//                        HIWORD - reserved
//                        HIBYTE(LOWORD) - major number
//                        LOBYTE(LOWORD) - minor number
//
/////////////////////////////////////////////////////////////////////////////
ExportFunc DWORD GetConduitVersion()
{
    return GENERIC_CONDUIT_VERSION;
}

/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
//
//       Function:     ConfigureConduit
//
//       Description:  Extern "C" entry point into this conduit which returns
//                     should display the UI necessary to configure this 
//                     conduit.
//
//       Parameters:   none
//
//       Returns:      0 - success, !0 - failure
//
/////////////////////////////////////////////////////////////////////////////
ExportFunc long ConfigureConduit(CSyncPreference& pref)
{

    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;
}

/////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////
//
//   Method:        GetConduitInfo
//
//   Description:   This function provides a way for a Conduit to provide 
//                  info to the caller.  In this version of the call, MFC 
//                  Version, Conduit Name, and Default sync action are the 
//                  types of information this call will return.
//
//   Parameters:    ConduitInfoEnum infoType - enum specifying what info is 
//                                             being requested.
//
//                  void *pInArgs - This parameter may be null, except for 
//                                  the Conduit name enum, this value will 
//                                  be a ConduitRequestInfoType structure.
//
//                  This following two parameters vary depending upon the 
//                  info being requested. 
//
//                  For enum eConduitName
//                  void *pOut - will be a pointer to a character buffer
//                  DWORD *pdwOutSize - will be a pointer to a DWORD 
//                                      specifying the size of the 
//                                      character buffer.
//
//                  For enum eMfcVersion
//                  void *pOut - will be a pointer to a DWORD
//                  DWORD *pdwOutSize - will be a pointer to a DWORD 
//                                      specifying the size of pOut.
//
//                  For enum eDefaultAction
//                  void *pOut - will be a pointer to a eSyncType variable
//                  DWORD *pdwOutSize - will be a pointer to a DWORD 
//                                      specifying the size of pOut.
//
//   Returns:       0   - Success.
//                  !0  - error code.
//
/////////////////////////////////////////////////////////////////////////////
ExportFunc long GetConduitInfo(ConduitInfoEnum infoType, void *pInArgs, 
                               void *pOut, DWORD *pdwOutSize)
{
    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;
}

long CALLBACK CondCfgDlgProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    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;
}

void LdCfgDlgBmps(HWND hDlg)
{
  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);
  }
}