⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cc

📁 源代码
💻 CC
字号:
/* Created by Anjuta version 0.1.9 *//*	This file will not be overwritten */#include <iostream.h>#include <syncml.h>#undef PACKAGE#undef VERSION#include <cc++/socket.h>using namespace ost;class myBase : public SyncMLDatabase { public:  myBase() : SyncMLDatabase() {    setURI(SMLURI("http://syncclient.org/contacts"));        SMLDevInf::DataStore s;    s.SourceRef="/contacts";    s.DisplayName="Contact Database";    s.Rx.insert(pair<string,string>("text/vcard","3.0"));    s.RxPref = pair<string,string>("text/vcard","3.0");    s.Tx.insert(pair<string,string>("text/vcard","3.0"));    s.TxPref = pair<string,string>("text/vcard","3.0");    s.SyncCap[SMLSyncType::twoway] = true;    s.SyncCap[SMLSyncType::slow] = true;    getDevInf()->setDataStore(s);  };  virtual SMLErrorType sendAll(SMLSessionHandler *handler, SMLTreeNode *n);  virtual string lastSyncWith(SMLURI u);};SMLErrorType myBase::sendAll(SMLSessionHandler *handler, SMLTreeNode *n) {  handler->sendAdd(n,0,0,0,"BEGIN:VCARD\nEND:VCARD\n");  return SMLError::Successful;}string myBase::lastSyncWith(SMLURI u) {  return "010101";}class mySesHandler: public SMLSessionHandler {public:  mySesHandler() : SMLSessionHandler() {    SMLDevInf *s = new SMLDevInf;    s->setOEM("GNU");    setDevInf(s);  }  ~mySesHandler() {    delete getDevInf();  }  virtual void sendAlerts() {    sendDisplay("Single Data");    vector<string> s;    s.push_back("Multiple Data Nr. 1");    s.push_back("Multiple Data Nr. 2");    s.push_back("Multiple Data Nr. 3");    sendDisplay(s);    sendTwoWaySync(SMLURI("http://syncclient.org/contacts"),SMLURI("http://syncserver.org/contacts"),"");    sendDevInf();    requestDevInf();  }};  int main(){  TCPStream *s = new TCPStream(InetHostAddress("192.168.11.10"),1234);  cout << "running...";  SyncMLSingleThread *tester = new SyncMLSingleThread();  mySesHandler *ses = new mySesHandler();  ses->addDatabase(new myBase);  tester->connect(s,s,SMLURI("http://syncclient.org","TestClient"),SMLURI("http://syncserver.org"), ses);  SMLDevInf* rd = ses->getRemoteDevInf();  if (rd) rd->save(&cout); else cout << "sorry, no device Information" << endl;  cout << "finished" << endl;      delete s;  	return (0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -