bool SyncManagerConfig::setSyncSourceConfig(SyncSourceConfig& sc) {
    unsigned int i=0;
    for (i=0; i<sourceConfigsCount; ++i) {
        if (strcmp(sc.getName(), sourceConfigs[i].getName()) == 0) {
            break;
        }
    }

    if (i >= sourceConfigsCount) {
        //
        // Not found! -> add the SyncSourceConfig.
        //
        return addSyncSourceConfig(sc);
    }

    if ( strcmp( sc.getName(), "mail") == 0 ){
        ((MailSyncSourceConfig&)(sourceConfigs[i])).assign(((MailSyncSourceConfig&)(sourceConfigs[i])));
    }else{
        sourceConfigs[i].assign(sc);
    }
    //dirty |= DIRTY_SYNC_SOURCE;

    return true;
}
/*
 * Add the passed SyncSourceConfig (the object is copied).
 * If SyncSourceConfig name is already present (match name) the
 * config is replaced with the given one.
 * Otherwise it is added in the sourceConfig array.
 */
bool SyncManagerConfig::addSyncSourceConfig(SyncSourceConfig& sc) {

    unsigned int i = 0;
    SyncSourceConfig* s = NULL;

    // copy array in a tmp buffer
    if (sourceConfigsCount > 0) {
        s = new SyncSourceConfig[sourceConfigsCount];
        for (i=0; i<sourceConfigsCount; i++) {
            if (strcmp(sourceConfigs[i].getName(), "mail") == 0) {
                ((MailSyncSourceConfig&)s[i]).assign(((MailSyncSourceConfig&)(sourceConfigs[i])));
            } else {
                s[i].assign(sourceConfigs[i]);
            }
        }       
    }

    // delete old one, create new (+1 element)
    if (sourceConfigs) {
        delete [] sourceConfigs;
    }

    sourceConfigs = new SyncSourceConfig[sourceConfigsCount + 1];
    // copy back.
    for (i = 0; i < sourceConfigsCount; i++) {
        if (strcmp(s[i].getName(), "mail") == 0) {
            ((MailSyncSourceConfig &)sourceConfigs[i]).assign(((MailSyncSourceConfig&)(s[i])));
        } else {
            sourceConfigs[i].assign(s[i]);
        }
    }
    
    sourceConfigsCount++;
    if (strcmp(sc.getName(), "mail") == 0) {
        ((MailSyncSourceConfig&)(sourceConfigs[i])).assign(((MailSyncSourceConfig&)(sc)));
    } else {
        sourceConfigs[i].assign(sc);
    }

    if (s) {
        delete [] s;
    }

    return true;
}
WindowsSyncSource* createAppointmentWindowsSyncSource() {

    OutlookConfig* config = getConfig();
    config->getServerConfig().setNoFieldLevelReplace("event");

    WIN_ASSERT_NOT_NULL(config, TEXT("The config is null. Please verify the an Outlook client is already installed"));
    SyncSourceConfig* sc = config->getSyncSourceConfig(APPOINTMENT_);
    WindowsSyncSource* ss = new WindowsSyncSource(APPOINTMENT, sc);
    int ret = ss->beginSync();   
    WIN_ASSERT_ZERO(ret, TEXT("beginSync is not 0"));

    SyncSourceReport* ssReport = new SyncSourceReport();
    ssReport->setSourceName(sc->getName());
    ssReport->setState(SOURCE_ACTIVE);
    ss->setReport(ssReport);

    return ss;

}
Example #4
0
void SyncSourceConfig::assign(const SyncSourceConfig& sc) {
    if (&sc == this) {
        return;
    }

    setName          (sc.getName          ());
    setURI           (sc.getURI           ());
    setSyncModes     (sc.getSyncModes     ());
    setType          (sc.getType          ());
    setSync          (sc.getSync          ());
    setLast          (sc.getLast          ());
    setEncoding      (sc.getEncoding      ());
    setVersion       (sc.getVersion       ());
    setSupportedTypes(sc.getSupportedTypes());
    setSyncMode      (sc.getSyncMode      ());
	setIsAllowed     (sc.isAllowed        ());
//    setCtCap         (sc.getCtCap         ());
    setEncryption    (sc.getEncryption    ());
    setLastSourceError(sc.getLastSourceError());
    setLastSyncServerTime(sc.AbstractSyncSourceConfig::getLastSyncServerTime());
    
    extraProps = sc.getExtraProps();
}