예제 #1
0
SyncSourceConfig* DefaultConfigFactory::getSyncSourceConfig(const char* name) {

    SyncSourceConfig* sc = new SyncSourceConfig();

    sc->setName                 (name);
    sc->setSyncModes            ("slow,two-way");
    sc->setSync                 ("two-way");
    sc->setEncoding             ("b64");
    sc->setLast                 (0);
    sc->setSupportedTypes       ("");
    sc->setVersion              ("");
    sc->setEncryption           ("");

    if (!strcmp(name, "contact")){
        sc->setURI              ("scard");
        sc->setType             ("text/x-s4j-sifc");
    }
    else if (!strcmp(name, "calendar")){
        sc->setURI              ("scal");
        sc->setType             ("text/x-s4j-sife");
    }
    else if (!strcmp(name, "task")){
        sc->setURI              ("stask");
        sc->setType             ("text/x-s4j-sift");
    }
    else if (!strcmp(name, "note")){
        sc->setURI              ("snote");
        sc->setType             ("text/x-s4j-sifn");
    }

    // *** TBD ***
    //sc->setCtCap

    return sc;
}
예제 #2
0
        void run() {
            AkonadiSource *source = appSource->getSyncSource();
            AppSyncSourceConfig* sourceConfig = appSource->getConfig();
            source->setCollectionId(sourceConfig->getCollectionId());
            SyncSourceConfig *srcConfig = KFunSyncConfig::getInstance()->getSyncSourceConfig(source->getName());
            if (srcConfig != NULL) {
                source->setConfig(srcConfig);
            }
            const char* remoteUri = sourceConfig->getRemoteUri();
            if (remoteUri == NULL || strlen(remoteUri) == 0) {
                sourceConfig->setRemoteUri(srcConfig->getURI());
                sourceConfig->save();
            } else {
                srcConfig->setURI(remoteUri);
            }

            SyncSource* ssArray[] = { source, NULL } ;
            if (client->sync(*KFunSyncConfig::getInstance(), ssArray)) {
                LOG.error("Error during sync.\n");
            }

            // Save the anchors
            KFunSyncConfig::getInstance()->save();
            manager->emitSourceEnded(appSource, client->getSyncReport());
        }
예제 #3
0
    void setUp() {

        // Create the output dir
        outputDir = getTestDirFullPath(TEST_INPUT_DIR);
        createFolder(outputDir.c_str());
        MediaSyncSourceParams params_;
        
        params_.setUrl(HTTPUPLOADER_URL);
        SyncSourceConfig* fssc = new SyncSourceConfig();
        fssc->setURI("testMss");
        // Create the FileSyncSource
        fmss = new FakeMediaSource(TEXT("testMss"), fssc, outputDir, params_);

        ssr = new SyncSourceReport("testMss");
        fmss->setReport(ssr);
    }
예제 #4
0
void doSync()
{
	using namespace Funambol;

	std::stringstream log;
	log << "Syncing: " << user << ":" << password << "@" << server << ". Calendar: " << doCalendar << ", Contacts: " << doContacts << ".";
	LOG.info(log.str().c_str());

	//create config object.
	StringMap env;
	env.put("HOME_FOLDER","/media/internal/.webOsSyncML");
	env.put("CONFIG_FOLDER","/media/internal/.webOsSyncML/config");
	PlatformAdapter::init("mobo/webOsSyncML",env);
	DMTClientConfig config;
	
	SyncSource* ssArray[3];
	int ssIndex = 0;
	ssArray[0] = ssArray[1] = ssArray[2] = NULL;

	//fill some config values
	if(!config.read()) 
	{
		PDL_GetDeviceName(buffer,BUFFERLEN);
		std::string id = "";//"webOsSyncML"; id.append(buffer);
		PDL_GetUniqueID(buffer,BUFFERLEN);
		id.append(buffer);
		//config.getDeviceConfig().setDevType("smartphone");
		config.getDeviceConfig().setDevID(id.c_str());
		config.getAccessConfig().setClientAuthType(AUTH_TYPE_MD5);
	}

	//fill access values:
	config.getAccessConfig().setSyncURL(server.c_str());
	config.getAccessConfig().setUsername(user.c_str());
	config.getAccessConfig().setPassword(password.c_str());

	WebOsCalendarSyncSource* calendar;
	WebOsContactsSyncSource* contacts;
	if(doCalendar)
	{
		SyncSourceConfig* calConfig = config.getSyncSourceConfig("calendar");
		if(!calConfig)
		{
			calConfig = DefaultConfigFactory::getSyncSourceConfig("calendar");
		}

		calConfig->setSyncModes("slow,two-way,refresh-from-server,refresh-from-client,one-way-from-server,one-way-from-client");
		calConfig->setSync(calendarMethod.c_str());
		calConfig->setURI(calendarDataStore.c_str());
		calConfig->setSupportedTypes("text/calendar");
		calConfig->setType("text/calendar");
		config.setSyncSourceConfig(*calConfig);
		calendar = new WebOsCalendarSyncSource(TEXT("calendar"),calConfig);
		ssArray[ssIndex] = calendar;
		ssIndex++;
	}

	if(doContacts)
	{
		SyncSourceConfig* conConfig = config.getSyncSourceConfig("contact");
		if(!conConfig)
		{
			conConfig = DefaultConfigFactory::getSyncSourceConfig("contact");
		}

		conConfig->setSyncModes("slow,two-way,refresh-from-server,refresh-from-client,one-way-from-server,one-way-from-client");
		conConfig->setSync(contactsMethod.c_str());
		conConfig->setSupportedTypes("text/x-vcard");
		conConfig->setType("text/x-vcard");
		conConfig->setURI(contactsDataStore.c_str());
		config.setSyncSourceConfig(*conConfig);
		contacts = new WebOsContactsSyncSource(TEXT("contact"),conConfig);
		ssArray[ssIndex] = contacts;
		ssIndex++;
	}

	//start sync process:
	SyncClient client;
	client.sync(config, ssArray);

	//save config options, includes configuration for next sync process:
	config.getAccessConfig().setPassword("");
	config.save();

	StringBuffer report;
	client.getSyncReport()->toString(report,true);
	LOG.info("Report: %s.",report.c_str());

	const char* params[2];
	if(doCalendar)
	{
		LOG.info("Cal_Error: %s (%d)",calendar->getReport()->getLastErrorMsg(),calendar->getReport()->getLastErrorCode());
		if(calendar->getReport()->getLastErrorCode() != 0)
			params[0] = "fail";
		else
			params[0] = "ok";
	}
	else
		params[0] = "ok";
	if(doContacts && contacts->getReport()->getLastErrorCode() != 0)
		params[1] = "fail";
	else
		params[1] = "ok";
 	PDL_CallJS("finished",params,2);

	for(int i = 0; i < ssIndex; i++)
	{
		delete ssArray[i];
		ssArray[i] = NULL;
	}
}
예제 #5
0
    TestFileSource(const std::string &id) :
        ClientTest(getenv("CLIENT_TEST_DELAY") ? atoi(getenv("CLIENT_TEST_DELAY")) : 0,
                   getenv("CLIENT_TEST_LOG") ? getenv("CLIENT_TEST_LOG") : ""),
        clientID(id) {
        const char *sourcelist = getenv("CLIENT_TEST_SOURCES");
        const char *server = getenv("CLIENT_TEST_SERVER");

        /* set up source list */
        if (!sourcelist) {
            sourcelist = "";
        }
        const char *eostr = strchr(sourcelist, ',');
        const char *start = sourcelist;

        while (eostr) {
            sources.push_back(std::string(start, 0, eostr - start));
            start = eostr + 1;
            eostr = strchr(start, ',');
        }
        if (start[0]) {
            sources.push_back(start);
        }

        /* check server */
        if (!server) {
            server = "funambol";
        }

        // get configuration and set obligatory fields
        LOG.setLevel(LOG_LEVEL_DEBUG);
        std::string root = std::string("client-test/") + server + "_" + id;
        config.reset(new DMTClientConfig(root.c_str()));
        config->read();
        DeviceConfig &dc(config->getDeviceConfig());
        if (!strlen(dc.getDevID())) {
            // no configuration yet
            config->setClientDefaults();
            dc.setDevID(id == "A" ? "sc-api-nat" : "sc-pim-ppc");
        }
        for (int source = 0; source < (int)sources.size(); source++) {
            ClientTest::Config testconfig;
            getSourceConfig(source, testconfig);
            CPPUNIT_ASSERT(testconfig.type);

            SyncSourceConfig* sc = config->getSyncSourceConfig(sources[source].c_str());
            if (!sc) {
                // no configuration yet
                config->setSourceDefaults(sources[source].c_str());
                sc = config->getSyncSourceConfig(sources[source].c_str());
                sc->setURI(testconfig.uri);
                CPPUNIT_ASSERT(sc);
            }

            sc->setType(testconfig.type);
        }
        config->save();
        config->open();

        if (id == "A") {
            /* we are the primary client, create a second one */
            clientB.reset(new TestFileSource("B"));
        }
    }