Esempio n. 1
0
int TestSyncSource::updateItem(SyncItem& item) {
    char* val = toMultibyte( item.getKey() );
    LOG.info("updated item: %s", val);
    if(val){
        delete [] val;
        val = 0;
    }

    char *data = new char [item.getDataSize()];
    memcpy(data, item.getData(), item.getDataSize());
    data[item.getDataSize()] = 0;
    LOG.info("Data: %s", data);
    delete [] data;

    return 200;
}
Esempio n. 2
0
int TestSyncSource::addItem(SyncItem& item) {
    char* val = toMultibyte( item.getKey() );
    LOG.info("added item: %s", val);
    if(val){
        delete [] val;
        val = 0;
    }
    char *data = new char [item.getDataSize()];
    memcpy(data, item.getData(), item.getDataSize());
    data[item.getDataSize()] = 0;
    LOG.info("Data: %s", data);
    delete [] data;

    WCHAR *luid = new WCHAR[wcslen(item.getKey())+10];
    wsprintf(luid, TEXT("%s-luid"), item.getKey());
    item.setKey(luid);

    return 200;
}
    //test te getFirstItem. We pass all the values into the properties ArrayList
    //and we get the first one
    void testAllItems() {
        ArrayList properties;
        ConfigSyncSource source(TEXT("config"), APPLICATIONURI, s);
        
        StringBuffer emailaddress("./Email/Address");
        
        properties.add(emailaddress);
        source.setConfigProperties(properties);

        Enumeration* val = source.getAllItemList();
        SyncItem* value = source.getFirstItem();
        StringBuffer valuedata((const char*)value->getData(),value->getDataSize());
        CPPUNIT_ASSERT(valuedata == VALUE);
	delete val;
	delete value;
    }
QString AbstractSyncSource::toString(SyncItem& item)
{
    QByteArray data((char *)item.getData());
    QString ret("Key: ");
    ret += item.getKey();
    ret += " Mod.Time: ";
    ret += QString::number(item.getModificationTime());
    ret += " Encoding: ";
    ret += item.getDataEncoding();
    ret += " Size: ";
    ret += QString::number(item.getDataSize());
    ret += " Type: ";
    ret += item.getDataType();
    ret += " State: ";
    ret += QString::number(item.getState());
    ret += " Data:\n";
    ret += data;
    return ret;
}