summaryrefslogtreecommitdiffstats
path: root/src/pedro/work/filesend.cpp
blob: 7a114abe25c38085018071e1010c01a4d75574d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <stdio.h>

#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;
}