#include #include "../libsyncml/include/syncml.h" #include #include #include void main() { /* ifstream f("x1.xml"); ifstream f2("x2.xml"); SyncML *bla = new SyncMLServer(&f,&cout); cout << "Return code is: " << bla->getLastErrorCode() << endl; delete bla; bla = new SyncMLServer(&f2,&cout); cout << "Return code is: " << bla->getLastErrorCode() << endl; delete bla; */ ifstream f3("devinf.xml"); cout << endl << "----------------------------------" << endl; SMLDevInf *di = new SMLDevInf(&f3); di->save(&cout); cout << endl << "----------------------------------" << endl; cout << di->getDevId(); cout << endl; cout << "Extensions: "; vector v = di->getExts(); copy(v.begin(),v.end(),ostream_iterator(cout," ")); cout << endl; cout << "FirstExt Values: "; v = di->getExtValues("FirstExt"); copy(v.begin(),v.end(),ostream_iterator(cout," ")); cout << endl; di->deleteExt("extbla"); di->deleteExt("FirstExt"); di->deleteExt("hmm"); cout << "Extensions: "; v = di->getExts(); copy(v.begin(),v.end(),ostream_iterator(cout," ")); cout << endl; v.clear(); v.push_back("value1"); v.push_back("value2"); di->setExtValues("extblup",v); di->setExtValues("test",v); di->save(&cout); delete di; cout << endl << "----------------------------------" << endl; di = new SMLDevInf(); di->setOEM("Max"); di->setFwV("1.0"); di->setMan("GNU"); di->setMod(""); SMLDevInf::DataStore store; store.SourceRef = "./addressbook"; store.SharedMem = true; store.MaxMem = 2048*1024; store.Rx.insert(pair("text/vcard","2.1")); store.Rx.insert(pair("text/vcard","4.0")); store.RxPref = pair("text/vcard","3.0"); store.Tx.insert(pair("text/vcalender","1.0")); store.TxPref = pair("text/vcalender","1.1"); store.SyncCap[SMLSyncType::twoway] = true; store.SyncCap[SMLSyncType::slow] = false; store.SyncCap[SMLSyncType::serverAlerted] = true; store.MaxID=1234; di->setDataStore(store); di->save(&cout); cout << endl << "----------------------------------" << endl; SMLDevInf::DataStore store2 = di->getDataStore("./addressbook"); delete di; SMLDevInf *di2 = new SMLDevInf(); di2->setDataStore(store2); SMLDevInf::CTCap cap; SMLDevInf::Prop prop; cap.CTType = "text/x-vcard"; prop.Name="BEGIN"; prop.ValEnum.push_back("VCARD"); cap.PropList.push_back(prop); prop.Name="END"; cap.PropList.push_back(prop); prop.ValEnum.clear(); prop.Name = "VERSION"; prop.ValEnum.push_back("2.1"); cap.PropList.push_back(prop); prop.ValEnum.clear(); prop.Name = "FN"; prop.DataType="chr"; prop.Size=20; cap.PropList.push_back(prop); prop.Size=0; prop.Name="N"; prop.DataType=""; cap.PropList.push_back(prop); prop.Name="TEL"; SMLDevInf::Param param; param.Name="WORK"; prop.ParamList.push_back(param); param.Name="HOME"; prop.ParamList.push_back(param); cap.PropList.push_back(prop); di2->setCTCap(cap); cap.CTType="text/x-vcalendar"; cap.PropList.clear(); prop.ParamList.clear(); prop.Name="BEGIN"; prop.ValEnum.push_back("VCALENDER"); prop.ValEnum.push_back("VEVENT"); cap.PropList.push_back(prop); prop.ValEnum.clear(); prop.Name="VERSION"; prop.ValEnum.push_back("1.0"); cap.PropList.push_back(prop); prop.ValEnum.clear(); prop.Name="DTSTART"; prop.DataType="datetime"; cap.PropList.push_back(prop); prop.Name="DTEND"; cap.PropList.push_back(prop); prop.Name="DESCRIPTION"; prop.DataType=""; cap.PropList.push_back(prop); di2->setCTCap(cap); di2->save(&cout); v = di->getCTCaps(); copy(v.begin(),v.end(),ostream_iterator(cout," ")); cout << endl; cout << endl << "----------------------------------" << endl; cap = di2->getCTCap("text/x-vcard"); di2->deleteCTCap("text/x-vcard"); di2->deleteCTCap("text/x-vcalendar"); di2->setCTCap(cap); di2->save(&cout); delete di2; }