Пример #1
0
bool FSyncOpt::parseCmdline(int args_num, char** args_val) 
{
    if (parser.parse(args_num, const_cast<const char **>(args_val), opts, args) == false) {
        return false;
    }

    if (optionSet("verbose")) {
        verbose = VERBOSE;
    } else if (optionSet("quiet")) {
        verbose = QUIET;
    }
    FSyncConfig *config = FSyncConfig::getInstance();

    // Get log options
    StringBuffer logLevelName = opts["loglevel"];
    if (!logLevelName.null()) {
        LogLevel logLevel;
        if (logLevelName == "error") {
            logLevel = LOG_LEVEL_NONE;
        } else if (logLevelName == "info") {
            logLevel = LOG_LEVEL_INFO;	
        } else if (logLevelName == "debug") {
            logLevel = LOG_LEVEL_DEBUG;
        } else {
            fprintf(stderr, "%s: unrecognized log level: '%s'\n",
                parser.getProgramName().c_str(), logLevelName.c_str());

            exit(EXIT_FAILURE);
        }
        config->getDeviceConfig().setLogLevel(logLevel);
        LOG.setLevel(config->getDeviceConfig().getLogLevel());
    }

    // Get server option
    StringBuffer serverUrl = opts["server"];
    if (!serverUrl.null()) {
        config->getAccessConfig().setSyncURL(serverUrl);
    }

    // Get local dir
    StringBuffer dir = opts["dir"];
    if (!dir.null()) {
        config->setSyncPath(dir);
        // TODO: reset anchors if different.
    }

    // Get username
    StringBuffer user = opts["user"];
    if (!user.null()) {
        config->getAccessConfig().setUsername(user);
    }

    // Get password (not secure, it's an example!) 
    StringBuffer pass = opts["password"];
    if (!pass.null()) {
        config->getAccessConfig().setPassword(pass);
    }

    return true;
}
Пример #2
0
    //////////////////////////////////////////////////////// Test /////
    // Test null() and empty() behavior
    void testEmpty() {
        StringBuffer s;
        CPPUNIT_ASSERT(s.empty());
        CPPUNIT_ASSERT(s.null());

        s = "";

        CPPUNIT_ASSERT( s.empty() );
        CPPUNIT_ASSERT( !s.null() );

    }
bool CCalendarSettings::saveSettings(bool saveToDisk)
{
    CString remoteName, outlookFolder, syncType;
    CString s1;
    _bstr_t bst;
    WindowsSyncSourceConfig* ssconf = ((OutlookConfig*)getConfig())->getSyncSourceConfig(APPOINTMENT_);

    GetDlgItemText(IDC_CALENDAR_EDIT_REMOTE, remoteName);
    GetDlgItemText(IDC_CALENDAR_EDIT_FOLDER, outlookFolder);

    // change values
    if(remoteName == ""){
        // remote name is empty
        s1.LoadString(IDS_ERROR_SET_REMOTE_NAME);
        wsafeMessageBox(s1);
        return false;
    }

    if (UICustomization::showWarningOnChangeFromOneWay) {
        int currentSyncType = getSyncTypeIndex(ssconf->getSync());
        int newSyncType = lstSyncType.GetCurSel();
        if (checkOneWayToTwoWay(currentSyncType, newSyncType)) {
           return false;
        }
    }

    // sync source enabled
    ssconf->setSync(getSyncTypeName(lstSyncType.GetCurSel()));

    // Date Filter
    int filterPos = lstFilter.GetCurSel();
    ssconf->getDateFilter().setRelativeLowerDate(getDateFilterValue(filterPos));


    // Note: use 'toMultibyte' which uses charset UTF-8.
    //       (when writing to winreg, toWideChar is then called)
    char* olFolder = toMultibyte(outlookFolder.GetBuffer());
    if (olFolder) {
        // If folder has changed, clear anchors
        if (UICustomization::clearAnchorsOnFolderChange) {
            const char * original = ssconf->getFolderPath();
            if (strcmp(original, olFolder) != 0) {
                ssconf->setLast(0);
                ssconf->setEndTimestamp(0);
            }
        }
        
        ssconf->setFolderPath(olFolder);
        delete [] olFolder;
    }

    if(checkInclude.GetCheck() == BST_CHECKED){
        ssconf->setUseSubfolders(true);
    }
    else {
        ssconf->setUseSubfolders(false);
    }

    StringBuffer remName;
    remName.convert(remoteName.GetBuffer());
    if (!remName.null()) {
        ssconf->setURI(remName.c_str());
    }   

    // Never save to winreg, will save when 'OK' is clicked on SyncSettings.
    //if(saveToDisk)
    //    ((OutlookConfig*)getConfig())->save();

    return true;
}