diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2011-01-25 16:15:27 +0100 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2011-01-25 16:15:27 +0100 |
commit | 758c5d62b5db02bebd4b1918a19bb7d22bfd9cb9 (patch) | |
tree | 54f18ed06ef091c71905943066d3680ffb5f152e | |
parent | d00c705d952d01baaae7b4d9976a74223387f551 (diff) |
TMimeDirProfileHandler::getOptionsFromDatastore(): clarify usage of session pointer
It is a bit confusing that TMimeDirProfileHandler::getOptionsFromDatastore()
depends on fRelatedDatastoreP to get a session pointer when it also
could use its own getSession(). The reason is that when running as part
of a script, fRelatedDatastoreP is NULL and thus copying the wrong
options for the remote peer from the session is avoided.
This patch clarifies that and replaces the many calls to
fRelatedDatastoreP->getSession() with a local variable. It also checks
that the result really isn't NULL.
-rw-r--r-- | src/sysync/mimedirprofile.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/sysync/mimedirprofile.cpp b/src/sysync/mimedirprofile.cpp index 0e8dfe9..b0b7a20 100644 --- a/src/sysync/mimedirprofile.cpp +++ b/src/sysync/mimedirprofile.cpp @@ -4516,20 +4516,24 @@ bool TMimeDirProfileHandler::parseLevels( void TMimeDirProfileHandler::getOptionsFromDatastore(void) { - // get options datastore if one is related - if (fRelatedDatastoreP) { - fReceiverCanHandleUTC = fRelatedDatastoreP->getSession()->fRemoteCanHandleUTC; - fVCal10EnddatesSameDay = fRelatedDatastoreP->getSession()->fVCal10EnddatesSameDay; - fReceiverTimeContext = fRelatedDatastoreP->getSession()->fUserTimeContext; // default to user context - fDontSendEmptyProperties = fRelatedDatastoreP->getSession()->fDontSendEmptyProperties; - fDefaultOutCharset = fRelatedDatastoreP->getSession()->fDefaultOutCharset; - fDefaultInCharset = fRelatedDatastoreP->getSession()->fDefaultInCharset; - fDoQuote8BitContent = fRelatedDatastoreP->getSession()->fDoQuote8BitContent; - fDoNotFoldContent = fRelatedDatastoreP->getSession()->fDoNotFoldContent; - fTreatRemoteTimeAsLocal = fRelatedDatastoreP->getSession()->fTreatRemoteTimeAsLocal; - fTreatRemoteTimeAsUTC = fRelatedDatastoreP->getSession()->fTreatRemoteTimeAsUTC; + // get options datastore if one is related; + // ignore the session from getSession() here because we need + // to distinguish between script context and normal sync context + // (the former has no datastore, the latter has) + TSyncSession *sessionP = fRelatedDatastoreP ? fRelatedDatastoreP->getSession() : NULL; + if (sessionP) { + fReceiverCanHandleUTC = sessionP->fRemoteCanHandleUTC; + fVCal10EnddatesSameDay = sessionP->fVCal10EnddatesSameDay; + fReceiverTimeContext = sessionP->fUserTimeContext; // default to user context + fDontSendEmptyProperties = sessionP->fDontSendEmptyProperties; + fDefaultOutCharset = sessionP->fDefaultOutCharset; + fDefaultInCharset = sessionP->fDefaultInCharset; + fDoQuote8BitContent = sessionP->fDoQuote8BitContent; + fDoNotFoldContent = sessionP->fDoNotFoldContent; + fTreatRemoteTimeAsLocal = sessionP->fTreatRemoteTimeAsLocal; + fTreatRemoteTimeAsUTC = sessionP->fTreatRemoteTimeAsUTC; #ifndef NO_REMOTE_RULES - fActiveRemoteRules = fRelatedDatastoreP->getSession()->fActiveRemoteRules; // copy the list + fActiveRemoteRules = sessionP->fActiveRemoteRules; // copy the list #endif } } |