I found the "MFC based DLL" to be too confusing, and/or not appropriate to
what I needed to do. I stripped out all but the basic Conduit entry points,
and then just wrote my own classes (except for the standard MFC Database and
utility classes (like CString, and CDialog (for configuration)). I don't
use CBaseMonitor or any of the Palm-supplied classes as they just don't work
like I need them to.
My Conduit entry point looks like this:
--------
ExportFunc long OpenConduit(PROGRESSFN pFn, CSyncProperties& rProps)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
long retval = -1;
if (pFn)
{
CONDHANDLE conduitHandle = (CONDHANDLE)0;
file://Activity syncFinishCode = slSyncFinished;
// If the conduit is set to do nothing, then make a note of it and
return.
if (rProps.m_SyncType == eDoNothing) {
LogAddEntry( "BioCruise - sync configured to Do Nothing.", slText,
false );
return 0;
}
// Register this conduit with SyncMgrDLL for communication to HH
retval = SyncRegisterConduit(conduitHandle);
if (retval) {
LogAddEntry("BioCruise - Unable to register conduit.", slText,
FALSE);
return (retval);
}
// Notify the log that a sync is about to begin
LogAddEntry("", slSyncStarted, FALSE);
// get name of database using conduitDll registry prefs
CDaoDatabase LocalDB;
CString dbName;
dbName = conduitDll.GetProfileString(_T("BioCruise"),
_T("CurrDBName"), NULL);
if (dbName.IsEmpty()) { // slText
LogAddEntry("BioCruise - No Target database - ", slText, FALSE);
retval = -1;
}
else {
try {
// returns 0 if user cancels, but we don't allow connect dialog
// so it will either succeed or throw an exception
LocalDB.Open(LPCSTR(dbName)); // allow shared access
if (!IsValidVersion(&LocalDB)) {
LogAddEntry("BioCruise - Invalid Version of TargetDB",
slSyncAborted, FALSE);
retval = -1;
}
else {
retval = CopyTablesFromHH(&LocalDB); // theRemoteDatabase );
if (!retval) {
LogAddEntry("BioCruise - from HH", slSyncFinished, FALSE);
retval = CopyTablesToHH(&LocalDB); // theRemoteDatabase );
if (!retval) // if success
LogAddEntry("BioCruise - to HH ", slSyncFinished,
FALSE);
}
if (retval)
LogAddEntry("BioCruise", slSyncAborted, FALSE);
}
}
catch (CDaoException* pEx) {
LogAddEntry("BioCruise - Unable to open TargetDB - ",
slSyncAborted, FALSE);
retval = -1;
pEx->Delete();
}
catch(char * str) {
CString msg;
msg.Format("BioCruise - Error on table: %s", str);
LogAddEntry(LPCSTR(msg), slSyncAborted, FALSE);
retval = -1;
}
if (LocalDB.IsOpen())
LocalDB.Close();
AfxDaoTerm();
}
SyncUnRegisterConduit(conduitHandle);
}
return (retval);
}
Note that I'm using CDaoDatabase and not CDatabase. CDaoDatabase is NOT
supported in the newer compilers and MS plans to drop support for DAO.
The CopyTablesToHH() function simply declares a CRecordset (actually
CDaoRecorset) class, opens it, and then copies the data to the appropriate
Palm table record by record. The CopyTablesFromHH() does the reverse.
--
-------------------------------------------------------------------------
Free software - Baxter Codeworks www.baxcode.com
-------------------------------------------------------------------------
Post by ClintonOk to get the afxdb.h into a palm conduit I had to start a new one
using the VC++ wizard. This time I created an MFC based DLL. I can now
create objects of type CDatabase, which should now allow me to
communicate with the database.
My problem now is that I don't quite understand the usage of this
conduit structure. Do I now have to create a new class to implement
CBaseMonitor even if I don't want to use it?
Basically my program has some data on the palm which it needs to store
in the ODBC database. After finishing that I want to perform some
queries on the ODBC database and put some data onto the palm... there
is no syncronisation, just an exchange of data. Can anyone see an
easier way of doing this?
Clinton