-
Notifications
You must be signed in to change notification settings - Fork 1
/
XMPP.h
106 lines (80 loc) · 2.89 KB
/
XMPP.h
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
96
97
98
99
100
101
102
103
104
105
106
/**Copyright 2012 Fabien LUCE
This file is part of Cptalk!.
Cptalk! is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Cptalk! is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Cptalk!. If not, see <http://www.gnu.org/licenses/>.**/
#ifndef XMPP_H
#define XMPP_H
class Linker;
class Core;
class Input;
class Output;
class CpClient;
#include "ICore.h"
#include <string>
#include "common.h"
#include <gloox/client.h>
#include <gloox/message.h>
#include <gloox/presencehandler.h>
#include <gloox/connectionlistener.h>
#include <gloox/messagesessionhandler.h>
#include <gloox/messagehandler.h>
#include <gloox/rosterlistener.h>
#include <gloox/rostermanager.h>
class Core: public ICore_XMPP {
public:
bool connected;
void register_linker(Linker& linker);
void register_cpclient(CpClient* cpclient);
void launch_output_refresh();
void launch_output_reset();
void send_line(Line line);
void write_string(string s);
void onConnect();
void onDisconnect(ConnectionError e);
bool onTLSConnect(const CertInfo& info);
void handleRosterPresence(const RosterItem &item, const std::string &resource, Presence::PresenceType presence, const std::string &msg);
void handleMessage(const Message& msg, MessageSession* session);
void handleMessageSession(MessageSession* session);
// Actions asked by any class having access to a Core
void list_roster();
void launch_connect();
void recv(int time);
void launch_disconnect();
void update_roster_choice();
// Session managing part
void print_session_id(const string bare); //just a temp function to retrieve session id from a bare jid
void list_sessions(); //just a temp function to list all current sessions in use
MessageSession* get_session_from_bare(const string bare); //just a temp function to retrieve session id from a bare jid
MessageSession* create_session(const string bare);
private:
/*Core_XMPP core_XMPP; //implementation*/
CpClient* ptr_cpclient;
Linker* ptr_linker;
};
void* connect_thread(void *objet);
class CpClient {
public:
void launch_connect();
void launch_disconnect();
void register_core(Core* co);
void define_client(Client* cl);
Roster* get_roster();
Client* get_client();
vector<MessageSession*> get_session_list();
MessageSession* get_session_from_bare(const string bare);
void register_session(MessageSession* session);
void store_session(MessageSession* session);
void recv(int t);
private:
Client* ptr_client;
vector<MessageSession*> session_list;
};
#endif