From a653ca13793bb191b8bb3c0c9d6c8c76554f64ef Mon Sep 17 00:00:00 2001 From: daleharvey Date: Sun, 25 Jun 2006 12:57:59 +0000 Subject: [PATCH] restored pedro/work and added it to make.exclude --- src/make.exclude | 2 +- src/pedro/work/filerec.cpp | 130 ++++++++++++ src/pedro/work/filesend.cpp | 95 +++++++++ src/pedro/work/groupchat.cpp | 225 +++++++++++++++++++++ src/pedro/work/inklayout.svg | 378 +++++++++++++++++++++++++++++++++++ src/pedro/work/test.cpp | 183 +++++++++++++++++ 6 files changed, 1012 insertions(+), 1 deletion(-) create mode 100644 src/pedro/work/filerec.cpp create mode 100644 src/pedro/work/filesend.cpp create mode 100644 src/pedro/work/groupchat.cpp create mode 100644 src/pedro/work/inklayout.svg create mode 100644 src/pedro/work/test.cpp diff --git a/src/make.exclude b/src/make.exclude index f7e5a4562..4c9afd7f8 100644 --- a/src/make.exclude +++ b/src/make.exclude @@ -46,7 +46,7 @@ winmain.cpp xml/quote-test.cpp xml/repr-action-test.cpp io/streamtest.cpp - +pedro/work ############################################### # Bob: diff --git a/src/pedro/work/filerec.cpp b/src/pedro/work/filerec.cpp new file mode 100644 index 000000000..01d9b6bd8 --- /dev/null +++ b/src/pedro/work/filerec.cpp @@ -0,0 +1,130 @@ + + +#include + +#include "pedroxmpp.h" + +//######################################################################## +//# T E S T +//######################################################################## + + +class TestListener : public Pedro::XmppEventListener +{ +public: + TestListener() + { + incoming = false; + } + + virtual ~TestListener(){} + + virtual void processXmppEvent(const Pedro::XmppEvent &evt) + { + int typ = evt.getType(); + switch (typ) + { + case Pedro::XmppEvent::EVENT_STATUS: + { + printf("STATUS: %s\n", evt.getData().c_str()); + break; + } + case Pedro::XmppEvent::EVENT_ERROR: + { + printf("ERROR: %s\n", evt.getData().c_str()); + break; + } + case Pedro::XmppEvent::EVENT_CONNECTED: + { + printf("CONNECTED\n"); + break; + } + case Pedro::XmppEvent::EVENT_DISCONNECTED: + { + printf("DISCONNECTED\n"); + break; + } + case Pedro::XmppEvent::EVENT_MUC_PRESENCE: + { + printf("MUC PRESENCE\n"); + printf("group : %s\n", evt.getGroup().c_str()); + printf("from : %s\n", evt.getFrom().c_str()); + printf("presence: %d\n", evt.getPresence()); + break; + } + case Pedro::XmppEvent::EVENT_FILE_RECEIVE: + { + printf("FILE RECEIVE\n"); + from = evt.getFrom(); + streamId = evt.getStreamId(); + iqId = evt.getIqId(); + fileName = evt.getFileName(); + fileHash = evt.getFileHash(); + fileSize = evt.getFileSize(); + incoming = true; + break; + } + + } + } + + Pedro::DOMString from; + Pedro::DOMString streamId; + Pedro::DOMString iqId; + Pedro::DOMString fileName; + Pedro::DOMString fileHash; + long fileSize; + bool incoming; +}; + + +bool doTest() +{ + printf("############ RECEIVING FILE\n"); + + Pedro::XmppClient client; + TestListener listener; + client.addXmppEventListener(listener); + + //Host, port, user, pass, resource + if (!client.connect("jabber.org.uk", 443, "ishmal", "PASSWORD", "filerec")) + { + printf("Connect failed\n"); + return false; + } + + while (true) + { + printf("####Waiting for file\n"); + if (listener.incoming) + break; + client.pause(2000); + } + + printf("#####GOT A FILE\n"); +/* +TODO: Just Commented out to compile + if (!client.fileReceive(listener.from, + listener.iqId, + listener.streamId, + listener.fileName, + "text.sav", + listener.fileHash)) + { + return false; + } +*/ + client.pause(1000000); + + client.disconnect(); + + return true; +} + +int main(int argc, char **argv) +{ + if (!doTest()) + return 1; + return 0; +} + diff --git a/src/pedro/work/filesend.cpp b/src/pedro/work/filesend.cpp new file mode 100644 index 000000000..7a114abe2 --- /dev/null +++ b/src/pedro/work/filesend.cpp @@ -0,0 +1,95 @@ + + +#include + +#include "pedroxmpp.h" + +//######################################################################## +//# T E S T +//######################################################################## + + +class TestListener : public Pedro::XmppEventListener +{ +public: + TestListener(){} + + virtual ~TestListener(){} + + virtual void processXmppEvent(const Pedro::XmppEvent &evt) + { + int typ = evt.getType(); + switch (typ) + { + case Pedro::XmppEvent::EVENT_STATUS: + { + printf("STATUS: %s\n", evt.getData().c_str()); + break; + } + case Pedro::XmppEvent::EVENT_ERROR: + { + printf("ERROR: %s\n", evt.getData().c_str()); + break; + } + case Pedro::XmppEvent::EVENT_CONNECTED: + { + printf("CONNECTED\n"); + break; + } + case Pedro::XmppEvent::EVENT_DISCONNECTED: + { + printf("DISCONNECTED\n"); + break; + } + case Pedro::XmppEvent::EVENT_MUC_PRESENCE: + { + printf("MUC PRESENCE\n"); + printf("group : %s\n", evt.getGroup().c_str()); + printf("from : %s\n", evt.getFrom().c_str()); + printf("presence: %d\n", evt.getPresence()); + break; + } + + } + } +}; + + +bool doTest() +{ + printf("############ SENDING FILE\n"); + + Pedro::XmppClient client; + TestListener listener; + client.addXmppEventListener(listener); + + //Host, port, user, pass, resource + if (!client.connect("jabber.org.uk", 443, "ishmal", "PASSWORD", "filesend")) + { + printf("Connect failed\n"); + return false; + } + + + if (!client.fileSend("ishmal@jabber.org.uk/filerec", + "server.pem" , "server.pem", + "a short story by edgar allen poe")) + { + return false; + } + + printf("OK\n"); + client.pause(1000000); + + client.disconnect(); + + return true; +} + +int main(int argc, char **argv) +{ + if (!doTest()) + return 1; + return 0; +} + diff --git a/src/pedro/work/groupchat.cpp b/src/pedro/work/groupchat.cpp new file mode 100644 index 000000000..6c2e186d9 --- /dev/null +++ b/src/pedro/work/groupchat.cpp @@ -0,0 +1,225 @@ + + +#include +#include + +#include "pedroxmpp.h" + +//######################################################################## +//# T E S T +//######################################################################## + +using namespace Pedro; + + +class Listener : public Pedro::XmppEventListener +{ +public: + Listener(){} + + virtual ~Listener(){} + + virtual void processXmppEvent(const Pedro::XmppEvent &evt) + { + int typ = evt.getType(); + switch (typ) + { + case Pedro::XmppEvent::EVENT_STATUS: + { + printf("STATUS: %s\n", evt.getData().c_str()); + break; + } + case Pedro::XmppEvent::EVENT_ERROR: + { + printf("ERROR: %s\n", evt.getData().c_str()); + break; + } + case Pedro::XmppEvent::EVENT_CONNECTED: + { + printf("CONNECTED\n"); + break; + } + case Pedro::XmppEvent::EVENT_DISCONNECTED: + { + printf("DISCONNECTED\n"); + break; + } + case Pedro::XmppEvent::EVENT_MESSAGE: + { + printf("<%s> %s\n", evt.getFrom().c_str(), evt.getData().c_str()); + break; + } + case Pedro::XmppEvent::EVENT_PRESENCE: + { + printf("PRESENCE\n"); + printf("from : %s\n", evt.getFrom().c_str()); + //printf("presence : %s\n", evt.getPresence().c_str()); + // TODO: Just Commented out to compile + break; + } + case Pedro::XmppEvent::EVENT_MUC_MESSAGE: + { + printf("<%s> %s\n", evt.getFrom().c_str(), evt.getData().c_str()); + break; + } + case Pedro::XmppEvent::EVENT_MUC_JOIN: + { + printf("MUC JOIN\n"); + printf("group: %s\n", evt.getGroup().c_str()); + printf("from : %s\n", evt.getFrom().c_str()); + //printf("presence: %s\n", evt.getPresence().c_str()); + // TODO: Just Commented out to compile + break; + } + case Pedro::XmppEvent::EVENT_MUC_LEAVE: + { + printf("MUC LEAVE\n"); + printf("group: %s\n", evt.getGroup().c_str()); + printf("from : %s\n", evt.getFrom().c_str()); + //printf("presence: %s\n", evt.getPresence().c_str()); + // TODO: Just Commented out to compile + break; + } + case Pedro::XmppEvent::EVENT_MUC_PRESENCE: + { + printf("MUC PRESENCE\n"); + printf("group : %s\n", evt.getGroup().c_str()); + printf("from : %s\n", evt.getFrom().c_str()); + //printf("presence: %s\n", evt.getPresence().c_str()); + // TODO: Just Commented out to compile + break; + } + + } + } +}; + + +class CommandLineGroupChat +{ +public: + CommandLineGroupChat(const DOMString &hostArg, + int portArg, + const DOMString &userArg, + const DOMString &passArg, + const DOMString &resourceArg, + const DOMString &groupJidArg, + const DOMString &nickArg) + { + host = hostArg; + port = portArg; + user = userArg; + pass = passArg; + resource = resourceArg; + groupJid = groupJidArg; + nick = nickArg; + } + ~CommandLineGroupChat() + { + client.disconnect(); + } + + virtual bool run(); + virtual bool processCommandLine(); + +private: + + DOMString host; + int port; + DOMString user; + DOMString pass; + DOMString resource; + DOMString groupJid; + DOMString nick; + + XmppClient client; + +}; + + +bool CommandLineGroupChat::run() +{ + Listener listener; + client.addXmppEventListener(listener); + + //Host, port, user, pass, resource + if (!client.connect(host, port, user, pass, resource)) + { + return false; + } + + //Group jabber id, nick, pass + if (!client.groupChatJoin(groupJid, nick, "")) + { + printf("failed join\n"); + return false; + } + + //Allow receive buffer to clear out + client.pause(10000); + + while (true) + { + if (!processCommandLine()) + break; + } + + //Group jabber id, nick + client.groupChatLeave(groupJid, nick); + + + client.disconnect(); + + return true; +} + + +bool CommandLineGroupChat::processCommandLine() +{ + char buf[512]; + printf("send>:"); + fgets(buf, 511, stdin); + + if (buf[0]=='/') + { + if (strncmp(buf, "/q", 2)==0) + return false; + else + { + printf("Unknown command\n"); + return true; + } + } + + else + { + DOMString msg = buf; + if (msg.size() > 0 ) + { + if (!client.groupChatMessage(groupJid, buf)) + { + printf("failed message send\n"); + return false; + } + } + } + + return true; +} + + +int main(int argc, char **argv) +{ + if (argc!=8) + { + printf("usage: %s host port user pass resource groupid nick\n", argv[0]); + return 1; + } + int port = atoi(argv[2]); + CommandLineGroupChat groupChat(argv[1], port, argv[3], argv[4], + argv[5], argv[6], argv[7]); + if (!groupChat.run()) + return 1; + return 0; +} + diff --git a/src/pedro/work/inklayout.svg b/src/pedro/work/inklayout.svg new file mode 100644 index 000000000..5f28a129b --- /dev/null +++ b/src/pedro/work/inklayout.svg @@ -0,0 +1,378 @@ + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + Private chat + + Gui Client Main Window + + Group chat + + Dialog + + + + Inkboard Layout + + Session + + Session Manager + + Session + + Session + + Private chat + w/ group member + Dialog + Dialog + + + + + + diff --git a/src/pedro/work/test.cpp b/src/pedro/work/test.cpp new file mode 100644 index 000000000..f822ceca9 --- /dev/null +++ b/src/pedro/work/test.cpp @@ -0,0 +1,183 @@ + + +#include + +#include "pedroxmpp.h" +#include "pedroconfig.h" + +//######################################################################## +//# T E S T +//######################################################################## + + +class TestListener : public Pedro::XmppEventListener +{ +public: + TestListener(){} + + virtual ~TestListener(){} + + virtual void processXmppEvent(const Pedro::XmppEvent &evt) + { + int typ = evt.getType(); + switch (typ) + { + case Pedro::XmppEvent::EVENT_STATUS: + { + printf("STATUS: %s\n", evt.getData().c_str()); + break; + } + case Pedro::XmppEvent::EVENT_ERROR: + { + printf("ERROR: %s\n", evt.getData().c_str()); + break; + } + case Pedro::XmppEvent::EVENT_CONNECTED: + { + printf("CONNECTED\n"); + break; + } + case Pedro::XmppEvent::EVENT_DISCONNECTED: + { + printf("DISCONNECTED\n"); + break; + } + case Pedro::XmppEvent::EVENT_MESSAGE: + { + printf("MESSAGE\n"); + printf("from : %s\n", evt.getFrom().c_str()); + printf("msg : %s\n", evt.getData().c_str()); + break; + } + case Pedro::XmppEvent::EVENT_PRESENCE: + { + printf("PRESENCE\n"); + printf("from : %s\n", evt.getFrom().c_str()); + printf("presence : %d\n", evt.getPresence()); + break; + } + case Pedro::XmppEvent::EVENT_MUC_MESSAGE: + { + printf("MUC GROUP MESSAGE\n"); + printf("group: %s\n", evt.getGroup().c_str()); + printf("from : %s\n", evt.getFrom().c_str()); + printf("msg : %s\n", evt.getData().c_str()); + break; + } + case Pedro::XmppEvent::EVENT_MUC_JOIN: + { + printf("MUC JOIN\n"); + printf("group: %s\n", evt.getGroup().c_str()); + printf("from : %s\n", evt.getFrom().c_str()); + printf("presence: %d\n", evt.getPresence()); + break; + } + case Pedro::XmppEvent::EVENT_MUC_LEAVE: + { + printf("MUC LEAVE\n"); + printf("group: %s\n", evt.getGroup().c_str()); + printf("from : %s\n", evt.getFrom().c_str()); + printf("presence: %d\n", evt.getPresence()); + break; + } + case Pedro::XmppEvent::EVENT_MUC_PRESENCE: + { + printf("MUC PRESENCE\n"); + printf("group : %s\n", evt.getGroup().c_str()); + printf("from : %s\n", evt.getFrom().c_str()); + printf("presence: %d\n", evt.getPresence()); + break; + } + + } + } +}; + + +bool doTest() +{ + printf("############ TESTING\n"); + + char *groupJid = "inkscape@conference.gristle.org"; + + Pedro::XmppClient client; + TestListener listener; + client.addXmppEventListener(listener); + + //Host, port, user, pass, resource + if (!client.connect("jabber.org.uk", 443, "ishmal", "PASSWORD", "myclient")) + { + printf("Connect failed\n"); + return false; + } + + //Group jabber id, nick, pass + client.groupChatJoin(groupJid, "mynick", ""); + + client.pause(8000); + + //Group jabber id, nick, msg + //client.groupChatMessage(groupJid, "hello, world"); + + client.pause(3000); + + //client.groupChatGetUserList(groupJid); + + client.pause(3000); + + //client.groupChatPrivateMessage("inkscape2@conference.gristle.org", + // "ishmal", "hello, world"); + client.message("ishmal@jabber.org.uk/https", "hey, bob"); + + client.pause(60000); + + //Group jabber id, nick + client.groupChatLeave(groupJid, "mynick"); + + client.pause(1000000); + + client.disconnect(); + + return true; +} + + +bool configTest() +{ + printf("#################################\n"); + printf("## C o n f i g t e s t\n"); + printf("#################################\n"); + + Pedro::XmppConfig config; + + if (!config.readFile("pedro.ini")) + { + printf("could not read config file\n"); + return false; + } + + Pedro::DOMString str = config.toXmlBuffer(); + + printf("#################################\n"); + printf("%s\n", str.c_str()); + + if (!config.writeFile("pedro2.ini")) + { + printf("could not write config file\n"); + return false; + } + + + return true; + +}; + + + +int main(int argc, char **argv) +{ + if (!configTest()) + return 1; + return 0; +} + -- 2.30.2