示例#1
0
文件: main.cpp 项目: Camelek/qtmoko
    // Advance the time on the desktop by 1 day then do a sync.
    void test5_1()
    {
        NEW_SYNC();
        server->nextSync = server->nextSync.addDays(1);

        QVERIFY(performSync());
    }
示例#2
0
文件: main.cpp 项目: Camelek/qtmoko
    // Edit the record on the server, see it edited on the client
    // Note that the mapping is used to translate the id
    void test1_2()
    {
        NEW_SYNC();
        QByteArray record = "<Record><Identifier>server.1</Identifier></Record>";
        server->do_edit.append(record);
        QByteArray expected = "<Record><Identifier>client.1</Identifier></Record>";
        client->expect_edit.append(expected);

        QVERIFY(performSync());
    }
示例#3
0
文件: main.cpp 项目: Camelek/qtmoko
    // Add a record on the client, see it on the server
    // The server will map the id
    void test1_1()
    {
        NEW_SYNC();
        QByteArray added = "<Record><Identifier>client.1</Identifier></Record>";
        QByteArray expected = "<Record><Identifier localIdentifier=\"false\">client.1</Identifier></Record>";
        client->do_add.append(added);
        server->expect_add.append(expected);
        server->expect_map.append("server.1 client.1");

        QVERIFY(performSync());
    }
示例#4
0
文件: main.cpp 项目: Camelek/qtmoko
    // Bogus edit on the server
    // Delete on the client
    // Note that this tests the conflict remove/edit where the server does and edit and the client does a remove.
    void test3_1()
    {
        NEW_SYNC();
        server->reference_schema = "<Contact><Identifier/><NameTitle/><FirstName pronunciation=\"\"/><MiddleName/><LastName pronunciation=\"\"/><Suffix/><Company pronunciation=\"\"/><BusinessWebpage/><JobTitle/><Department/><Office/><Profession/><Assistant/><Manager/><Spouse/><Nickname/><Children/><Birthday/><Anniversary/><Notes/><Gender/><Addresses/><PhoneNumbers/><EmailAddresses/><Categories/></Contact>";
        QByteArray serverChange = "<Contact><Identifier>server.2</Identifier><NameTitle></NameTitle><FirstName pronunciation=\"\">Foo</FirstName><MiddleName>Bar</MiddleName><LastName pronunciation=\"\">Baz</LastName><Suffix></Suffix><Company pronunciation=\"\"></Company><BusinessWebpage></BusinessWebpage><JobTitle></JobTitle><Department></Department><Office></Office><Profession></Profession><Assistant></Assistant><Manager></Manager><Spouse></Spouse><Nickname></Nickname><Children></Children><Birthday></Birthday><Anniversary></Anniversary><Notes></Notes><Gender>UnspecifiedGender</Gender><Addresses maxItems=\"2\"><Address type=\"Home\"><Street>745 street name</Street><City>city name</City><State>state</State><Zip>11111</Zip><Country>Austrealia</Country></Address><Address type=\"Business\"><Street></Street><City></City><State></State><Zip></Zip><Country></Country></Address></Addresses><PhoneNumbers maxItems=\"7\"><Number type=\"HomePhone\">555-5555</Number><Number type=\"HomeMobile\"></Number><Number type=\"HomeFax\"></Number><Number type=\"BusinessPhone\"></Number><Number type=\"BusinessMobile\"></Number><Number type=\"BusinessFax\"></Number><Number type=\"BusinessPager\"></Number></PhoneNumbers><EmailAddresses maxItems=\"3\"><Email>[email protected]</Email><Email></Email><Email></Email></EmailAddresses><Categories></Categories></Contact>";
        server->do_edit.append(serverChange);
        client->do_delete.append("client.2");
        server->expect_delete.append("server.2");

        QVERIFY(performSync());
    }
示例#5
0
文件: main.cpp 项目: Camelek/qtmoko
    // Keeping the desktop advanced by a day, edit a record on the server.
    void test5_3()
    {
        NEW_SYNC();
        server->nextSync = server->nextSync.addDays(1);

        QByteArray record = "<Record><Identifier>server.5</Identifier></Record>";
        server->do_edit.append(record);
        QByteArray expected = "<Record><Identifier>client.5</Identifier></Record>";
        client->expect_edit.append(expected);

        QVERIFY(performSync());
    }
示例#6
0
文件: main.cpp 项目: Camelek/qtmoko
    // Conflict remove/edit
    // Remove wins
    // This tests the client doing an edit and the server doing a delete. Test 3_1 tests the other way around.
    void test4_3()
    {
        NEW_SYNC();
        QByteArray clientEdit = "<Record><Identifier>client.4</Identifier><f1>foo</f1><f2>client</f2></Record>";
        QByteArray serverDelete = "server.4";
        QByteArray cExpected = "client.4";
        client->do_edit.append(clientEdit);
        server->do_delete.append(serverDelete);
        client->expect_delete.append(cExpected);

        QVERIFY(performSync());
    }
示例#7
0
文件: main.cpp 项目: Camelek/qtmoko
    // Conflict edit/edit
    // Client wins (edit on the server)
    void test4_2()
    {
        NEW_SYNC();
        QByteArray clientEdit = "<Record><Identifier>client.4</Identifier><f1>foo</f1><f2>client</f2></Record>";
        QByteArray serverEdit = "<Record><Identifier>server.4</Identifier><f1>client</f1><f2>foo</f2></Record>";
        QByteArray sExpected = "<Record><Identifier>server.4</Identifier><f1>foo</f1><f2>client</f2></Record>";
        server->do_edit.append(serverEdit);
        client->do_edit.append(clientEdit);
        server->expect_edit.append(sExpected);

        QVERIFY(performSync());
    }
示例#8
0
bool PodSync::processOneItem( FileInfo *pSrcInfo, FileInfo *pDstInfo )
{
    FileInfo info;
    // Assume things are ok
    bool result = true;
    const char *srcFileName;
    srcFileName = basename( pSrcInfo->getName() );

    // + 2 for the path separator and the final 0
    char *dstFileName = new char[ strlen( pDstInfo->getName() ) + strlen( srcFileName ) + 2 ];
    strcpy( dstFileName, pDstInfo->getName() );
    strcat( dstFileName, "/" );
    strcat( dstFileName, srcFileName );
    rInfo( "Processing %s", pSrcInfo->getName() );

    // Ok, destination does not exist, copy
    if( false == info.getInfo( dstFileName ))
    {
        if( false == pSrcInfo->isDir() )
        {
            rInfo( "Copying %s to %s as it does not exist", pSrcInfo->getName(), dstFileName ) ;
            result = copy( pSrcInfo->getName(), dstFileName );
        }
        else
        {
            // Current item in src is a dir, recurse
            const char *srcBaseName = basename( pSrcInfo->getName() );
            char *pNewDst = new char[ strlen( pDstInfo->getName() ) + strlen( srcBaseName ) + 2 ];
            strcpy( pNewDst, pDstInfo->getName() );
            strcat( pNewDst, "/" );
            strcat( pNewDst, srcBaseName );
            performSync( pSrcInfo->getName(), pNewDst );
            delete[] pNewDst;
        }
    }
    else
    {
        // Destination is older that source, copy
        if( info.getModificationTime() < pSrcInfo->getModificationTime() )
        {
            rInfo( "Copying %s to %s as it is newer", pSrcInfo->getName(), dstFileName ) ;
            result = copy( pSrcInfo->getName(), dstFileName );
        }
        else
        {
            rInfo( "Skipping %s as %s is up-to-date", pSrcInfo->getName(), dstFileName ) ;
        }
    }

    delete[] dstFileName;

    return result;
}
示例#9
0
文件: main.cpp 项目: Camelek/qtmoko
    // Reproduce something a customer has seen...
    // Add a record on the server, see it added on the client
    void test2_1()
    {
        NEW_SYNC();
        server->reference_schema = "<Contact><Identifier/><NameTitle/><FirstName pronunciation=\"\"/><MiddleName/><LastName pronunciation=\"\"/><Suffix/><Company pronunciation=\"\"/><BusinessWebpage/><JobTitle/><Department/><Office/><Profession/><Assistant/><Manager/><Spouse/><Nickname/><Children/><Birthday/><Anniversary/><Notes/><Gender/><Addresses/><PhoneNumbers/><EmailAddresses/><Categories/></Contact>";
        QByteArray record = "<Contact><Identifier>server.2</Identifier><NameTitle></NameTitle><FirstName pronunciation=\"\">Foo</FirstName><MiddleName>Bar</MiddleName><LastName pronunciation=\"\">Baz</LastName><Suffix></Suffix><Company pronunciation=\"\"></Company><BusinessWebpage></BusinessWebpage><JobTitle></JobTitle><Department></Department><Office></Office><Profession></Profession><Assistant></Assistant><Manager></Manager><Spouse></Spouse><Nickname></Nickname><Children></Children><Birthday></Birthday><Anniversary></Anniversary><Notes></Notes><Gender>UnspecifiedGender</Gender><Addresses maxItems=\"2\"><Address type=\"Home\"><Street></Street><City></City><State></State><Zip></Zip><Country></Country></Address><Address type=\"Business\"><Street></Street><City></City><State></State><Zip></Zip><Country></Country></Address></Addresses><PhoneNumbers maxItems=\"7\"><Number type=\"HomePhone\"></Number><Number type=\"HomeMobile\"></Number><Number type=\"HomeFax\"></Number><Number type=\"BusinessPhone\"></Number><Number type=\"BusinessMobile\"></Number><Number type=\"BusinessFax\"></Number><Number type=\"BusinessPager\"></Number></PhoneNumbers><EmailAddresses maxItems=\"3\"><Email></Email><Email></Email><Email></Email></EmailAddresses><Categories></Categories><CustomFields></CustomFields></Contact>";
        // Sorting affects the order of items
        QByteArray expect = "<Contact><Identifier localIdentifier=\"false\">server.2</Identifier><NameTitle></NameTitle><FirstName pronunciation=\"\">Foo</FirstName><MiddleName>Bar</MiddleName><LastName pronunciation=\"\">Baz</LastName><Suffix></Suffix><Company pronunciation=\"\"></Company><BusinessWebpage></BusinessWebpage><JobTitle></JobTitle><Department></Department><Office></Office><Profession></Profession><Assistant></Assistant><Manager></Manager><Spouse></Spouse><Nickname></Nickname><Children></Children><Birthday></Birthday><Anniversary></Anniversary><Notes></Notes><Gender>UnspecifiedGender</Gender><Addresses maxItems=\"2\"><Address type=\"Business\"><Street></Street><City></City><State></State><Zip></Zip><Country></Country></Address><Address type=\"Home\"><Street></Street><City></City><State></State><Zip></Zip><Country></Country></Address></Addresses><PhoneNumbers maxItems=\"7\"><Number type=\"BusinessFax\"></Number><Number type=\"BusinessMobile\"></Number><Number type=\"BusinessPager\"></Number><Number type=\"BusinessPhone\"></Number><Number type=\"HomeFax\"></Number><Number type=\"HomeMobile\"></Number><Number type=\"HomePhone\"></Number></PhoneNumbers><EmailAddresses maxItems=\"3\"><Email></Email><Email></Email><Email></Email></EmailAddresses><Categories></Categories></Contact>";
        server->do_add.append(record);
        client->expect_add.append(expect);
        client->expect_map.append("server.2 client.2");

        QVERIFY(performSync());
    }
示例#10
0
文件: main.cpp 项目: Camelek/qtmoko
    // Keeping the desktop advanced by a day, add a record on the client.
    void test5_2()
    {
        NEW_SYNC();
        server->nextSync = server->nextSync.addDays(1);

        QByteArray added = "<Record><Identifier>client.5</Identifier></Record>";
        QByteArray expected = "<Record><Identifier localIdentifier=\"false\">client.5</Identifier></Record>";
        client->do_add.append(added);
        server->expect_add.append(expected);
        server->expect_map.append("server.5 client.5");

        QVERIFY(performSync());
    }
示例#11
0
bool PodSync::doSync( void )
{
    bool result = true;
    const char *pDst = m_pConfig->getString( "destination_directory" );
    const char *pSrc = m_pConfig->getString( "source_directory" );
    if( 0 != pDst && 0 != pSrc )
    {
        rInfo( "Performing sync from %s to %s", pSrc, pDst );
        if( true == performSync( pSrc, pDst ))
        {
            rInfo( "Sync completed" );
        }
        else
        {
            rWarning( "Sync failed" );
        }
    }
    else
    {
        rWarning( "Bad config" );
        result = false;
    }
    return result;
}
示例#12
0
void
FeedHandler::sync()
{
    _writeService.master().execute(makeLambdaTask([this]() { performSync(); }));
    _writeService.sync();
}