This repository has been archived by the owner on Apr 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
kjabber_main.h
153 lines (123 loc) · 4.93 KB
/
kjabber_main.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
* kJabber
*
* Please READ & ACCEPT /License.txt FIRST!
*
* Copyright (C)2005,2006 Rafa³ Lindemann, STAMINA
* http://www.stamina.pl/ , http://www.konnekt.info/
*
* $Id: $
*/
#pragma once
using namespace jabberoo;
using namespace judo;
extern char nextSlot;
namespace kJabber {
CStdString LocaleToUTF8(CStdString txt);
CStdString UTF8ToLocale(CStdString utf8);
/* Obs³uga 'slota' jabberowego... W przysz³oœci na raz bêdzie
ich dzia³aæ kilka */
class cJabber : public cJabberBase , public SigC::Object {
public:
cJabber(cCtrl * ctrl); // inicjalizacja
// Podstawowa dzia³alnoœæ
void StartSSL();
int FindContact(const CStdString & jid);
int CompareJID(const CStdString & a, const CStdString & b);
/* Obs³uga komunikatów Konnekta */
int IMessageProc(sIMessage_base * msgBase);
int ActionCfgProc(sUIActionNotify_base * anBase);
int ActionProc(sUIActionNotify_base * anBase);
void UIPrepare();
void SetColumns();
void ActionRegisterAccount();
void ActionEditRegistration();
/* CFG */
enSynchDirection CFGsynchDirection() {return (enSynchDirection)plug->DTgetInt(DTCFG , 0 , kJabber::CFG::synchDirection);}
int CFGsynchRemoveContacts() {return plug->DTgetInt(DTCFG , 0 , CFG::synchRemoveContacts);}
int CFGsynchAddContacts() {return plug->DTgetInt(DTCFG , 0 , CFG::synchAddContacts);}
int CFGautoSubscribe() {return plug->DTgetInt(DTCFG , 0 , CFG::autoSubscribe);}
int CFGautoAuthorize() {return plug->DTgetInt(DTCFG , 0 , CFG::autoAuthorize);}
/* Interfejs ni¿szego poziomu */
const CStdString GetUID();
const CStdString GetHost(bool useReal) {
if (this->useHost.empty()) {
if (useReal == false || this->realHost.empty()) {
return plug->DTgetStr(DTCFG , 0 , plug->DTgetNameID(DTCFG , dtPrefix + "/host") );
} else {
return this->realHost;
}
} else {
return this->useHost;
}
}
int GetPort(bool useReal) {
if (useReal == true && this->realPort) {
return this->realPort;
} else {
return plug->DTgetInt(DTCFG , 0 , plug->DTgetNameID(DTCFG , dtPrefix + "/port") );
}
}
SOCKET GetSocket() {return socket;}
jabberoo::Session & GetSession() {return session;}
const CStdString & GetName();
int ACTcfgGroup() {return kJabber::ACT::CfgGroup + this->GetSlot();}
unsigned int ListenThread(void);
bool Connected() {
return socket && thread && session.getConnState() == jabberoo::Session::csConnected;
}
void DisconnectSocket();
void SetContact(int cntID , Roster::Item & item);
void SetContact(int cntID , void * item) {SetContact(cntID , *((Roster::Item*) item) );}
void SetRosterItem(int cntID);
void SetCntIcon(int cntID , int status , const CStdString & jid);
int GetCntIcon(int status , const CStdString & jid);
bool SendPresence(const CStdString & to , int status , const char * info);
bool SendSubRequest(const CStdString & to , bool subscribe);
bool SendSubscribed(const CStdString & to , bool subscribed);
bool SendCntSearch(sCNTSEARCH * sr);
bool SendVCardRequest(int cntID);
bool SendVCardSet(bool window);
bool SendMessage(cMessage * m);
bool RosterDeleteJID(const CStdString & jid);
bool RosterContainsJID(const CStdString & JID);
bool SendPing();
void CntSearch(sCNTSEARCH * sr);
void vCardSetEmail(judo::Element * vCard , CStdString email , const char * location);
void vCardSetPhone(judo::Element * vCard , CStdString phone , const char * type , const char * location);
judo::Element * vCardSetAddress(judo::Element * vCard , bool window , const CStdString & path);
void vCardGetValue(const judo::Element * vCard , bool window , int cnt , int col , const char * path);
// Eventy
void OnTransmitXML(const char* c);
void OnAuthError(int errorcode , const char* errormessage);
void OnDisconnected();
void OnConnected(const judo::Element& e);
void OnRoster(const judo::Element& e);
void OnMessage(const jabberoo::Message & m);
void OnPresence(const Presence& presence, Presence::Type previousType);
void OnPresenceRequest(const Presence & presence);
void OnVersion(string & name , string & version , string & os);
void OnLast(string & seconds);
void OnTime(string & localTime, string & timeZone);
void OnRosterItemRemoving(Roster::Item &);
void OnRosterItemUpdated(Roster::Item &);
void OnRosterItemAdded(Roster::Item &);
void OnIQSearchReply(const judo::Element&);
void OnIQVCardRequestReply(const judo::Element&);
void OnIQVCardSetReply(const judo::Element&);
void OnCantConnect(bool automated);
/* DODATKI */
void ServiceDiscovery(const CStdString jid);
DiscoDB::Item * GetDiscoItem(const CStdString &jid, bool items, bool fetch);
private:
jabberoo::Session session;
SOCKET socket;
SSL * ssl;
SSL_CTX * ssl_ctx;
CStdString priority;
bool canReconnect;
bool createAccount;
CStdString realHost;
unsigned short realPort;
};
}