summaryrefslogtreecommitdiffstats
path: root/src/pedro/work/filerec.cpp
diff options
context:
space:
mode:
authorBob Jamison <ishmalius@gmail.com>2006-05-15 15:06:21 +0000
committerishmal <ishmal@users.sourceforge.net>2006-05-15 15:06:21 +0000
commit8325c242bbc39df39b5b2260d3e2aac289d8a930 (patch)
tree9a910be0c78883d9beec6cece07f7f800e0713ae /src/pedro/work/filerec.cpp
parentfix potential (though currently impossible) crash when spatial mode is used w... (diff)
downloadinkscape-8325c242bbc39df39b5b2260d3e2aac289d8a930.tar.gz
inkscape-8325c242bbc39df39b5b2260d3e2aac289d8a930.zip
Move from the jabber_whiteboard directory to its own, so that it can be updated in parallel.
(bzr r846)
Diffstat (limited to 'src/pedro/work/filerec.cpp')
-rw-r--r--src/pedro/work/filerec.cpp129
1 files changed, 129 insertions, 0 deletions
diff --git a/src/pedro/work/filerec.cpp b/src/pedro/work/filerec.cpp
new file mode 100644
index 000000000..9fc8b8647
--- /dev/null
+++ b/src/pedro/work/filerec.cpp
@@ -0,0 +1,129 @@
+
+
+#include <stdio.h>
+
+#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");
+
+ 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;
+}
+