-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMsnp8.h
293 lines (228 loc) · 8.2 KB
/
Msnp8.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/* HellowCpp, alpha version
* (c) 2010 Gustavo Maia Neto (gutomaia)
*
* HellowPhp and all other Hellow flavors will be always
* freely distributed under the terms of an GPLv3 license.
*
* Human Knowledge belongs to the World!
*--------------------------------------------------------------------------*/
#ifndef MSNP8_H
#define MSNP8_H
#include <iostream>
#include <string>
#include "Notification.h"
using namespace std;
class Msnp8 : public Notification {
private:
string MSN_HOST;
int MSN_PORT;
string PROTOCOL_VERSION;
string LOCALE_ID;
string OS_TYPE;
string OS_VERSION;
string CPU_ARCHITECTURE;
string CLIENT_NAME;
string CLIENT_VERSION;
string CLIENT_ID;
string CLIENT_IDCODE;
string CLIENT_CODE;
protected:
string getUsername();
string getPassword();
public:
Msnp8(void);
void execute(string command);
string getProtocolVersion(){
return this->PROTOCOL_VERSION;
}
string getLocale(){
return this->LOCALE_ID;
}
string getOSType(){
return this->OS_TYPE;
}
string getOSVersion(){
return this->OS_VERSION;
}
string getArch(){
return this->CPU_ARCHITECTURE;
}
string getClientName(){
return this->CLIENT_NAME;
}
string getClientVersion(){
return this->CLIENT_VERSION;
}
string getClientId(){
return this->CLIENT_ID;
}
//virtual string getProtocolVersion(void);
/*
virtual string getLocale();
virtual string getOSType();
virtual string getOSVersion();
virtual string getArch();
virtual string getClientName();
virtual string getClientVersion();
virtual string getClientId();
virtual string getIdCode();
virtual string getCode();
*/
/*
public function setAuthenticationHandle($authenticationHandle) {
$this->_authenticationHandle = $authenticationHandle;
}
*/
/*
function ver() {
return "VER ". $this->_trid ." ".$this->getProtocolVersion()." CVR0". $this->EL;
}
function cvr() {
return "CVR " . $this->_trid . " " . $this->getLocale() . " " . $this->getOSType() . " " . $this->getOSVersion() . " " .
$this->getArch() . " " . $this->getClientName() . " " . $this->getClientVersion() . " " . $this->getClientId() . " " .
$this->getUsername() . $this->EL;
}
function usr() {
if ($this->_passport == null) {
return "USR " . $this->_trid . " TWN I " . $this->_username . $this->EL;
} else {
return "USR " . $this->_trid . " TWN S " . $this->_passport . $this->EL;
}
}
function syn() {
return "SYN 1 0" . $this->EL;
}
function chg() {
return "CHG " . $this->_trid . " NLN 0" . $this->EL;
}
function qry($chl = null) {
return "QRY ".$this->_trid . " ". $this->getIdCode(). " 32".$this->EL.$this->challenger($chl);
}
function challenger($chl) {
return md5($chl.$this->getCode());
}
function out() {
return "OUT" . $this->EL;
}
*/
};
#endif
/*
abstract class Hellow_Protocol_Notification extends Hellow_Protocol_Msnp{
abstract function getProtocolVersion();
abstract function getLocale();
abstract function getOSType();
abstract function getOSVersion();
abstract function getArch();
abstract function getClientName();
abstract function getClientVersion();
abstract function getClientId();
abstract function getIdCode();
abstract function getCode();
private $_authenticationHandle = null;
public function __construct() {
parent::__construct();
$this->_authenticationHandle = new Hellow_Auth_Tweener;
}
public function setAuthenticationHandle($authenticationHandle) {
$this->_authenticationHandle = $authenticationHandle;
}
protected function authenticate($lc){
$this->_passport = $this->_authenticationHandle->authenticate($this->_username, $this->_password, $lc);
}
private $_username = null;
private $_password = null;
private $_passport = null;
protected final function getUsername(){
return $this->_username;
}
protected final function getPassword(){
return $this->_password;
}
protected function connect($host, $port) {
if ($this->_username == null || $this->_password == null) {
//die('User or password null'); //TODO: see why
}
parent::connect($host, $port);
$this->send($this->ver());
$this->listen();
}
public function login($username, $password){
$this->_username = $username;
$this->_password = $password;
$this->connect($this->getHost(), $this->getPort());
}
public function logout() {
$this->send($this->out());
$this->disconnect();
}
private $_connectionListener = null;
private $_contactListener = null;
private $_presenceListener = null;
private $_callListener = null;
public final function addConnectionListener($connectionListener){
$this->_connectionListener = $connectionListener;
}
public final function addContactListener($contactListener){
$this->_contactListener = $contactListener;
}
public final function addPresenceListener($presenceListener){
$this->_presenceListener = $presenceListener;
}
public final function addCallListener($callListener){
$this->_callListener = $callListener;
}
//Connection
protected final function onLogged(){if(!empty($this->_connectionListener)) $this->_connectionListener->onLogged();}
protected final function onConnected(){if(!empty($this->_connectionListener)) $this->_connectionListener->onConnected();}
//Contact
protected final function onAddContact($user, $nick, $lists, $groups=null){if(!empty($this->_contactListener)){$this->_contactListener->onAddContact(array('user'=>$user, 'nick'=>$nick, 'lists'=>$lists, 'groups'=>$groups));}}
protected final function onRemoveContact($user){if(!empty($this->_contactListener)) $this->_contactListener->onRemoveContact($user);}
protected final function onAddGroup($id, $name, $unk=null){if(!empty($this->_contactListener)){$this->_contactListener->onAddGroup(array('group_id'=>$id, 'name'=>$name));}}
protected final function onRemoveGroup($group){}
// Presence
protected final function onContactOnline($contact){if(!empty($this->_presenceListener)) $this->_presenceListener->onContactOnline($contact);}
protected final function onContactOffline($contact){if(!empty($this->_presenceListener)) $this->_presenceListener->onContactOffline($contact);}
protected final function onContactAvaiable($contact){if(!empty($this->_presenceListener)) $this->_presenceListener->onContactAvaiable($contact);}
protected final function onContactBusy($contact){if(!empty($this->_presenceListener)) $this->_presenceListener->onContactBusy($contact);}
protected final function onContactIdle($contact){if(!empty($this->_presenceListener)) $this->_presenceListener->onContactIdle($contact);}
protected final function onContactBeRightBack($contact){if(!empty($this->_presenceListener)) $this->_presenceListener->onContactBeRightBack($contact);}
protected final function onContactAway($contact){if(!empty($this->_presenceListener)) $this->_presenceListener->onContactAway($contact);}
protected final function onContactOnPhone($contact){if(!empty($this->_presenceListener)) $this->_presenceListener->onContactOnPhone($contact);}
protected final function onContactOutLunch($contact){if(!empty($this->_presenceListener)) $this->_presenceListener->onContactOutLunch($contact);}
//Call
protected final function onRing($call, $server, $port, $cki, $username, $nick){
if(!empty($this->_callListener)) $this->_callListener->onRing($call, $server, $port, $cki, $username, $nick);
}
function ver() {
return "VER ". $this->_trid ." ".$this->getProtocolVersion()." CVR0". $this->EL;
}
function cvr() {
return "CVR " . $this->_trid . " " . $this->getLocale() . " " . $this->getOSType() . " " . $this->getOSVersion() . " " .
$this->getArch() . " " . $this->getClientName() . " " . $this->getClientVersion() . " " . $this->getClientId() . " " .
$this->getUsername() . $this->EL;
}
function usr() {
if ($this->_passport == null) {
return "USR " . $this->_trid . " TWN I " . $this->_username . $this->EL;
} else {
return "USR " . $this->_trid . " TWN S " . $this->_passport . $this->EL;
}
}
function syn() {
return "SYN 1 0" . $this->EL;
}
function chg() {
return "CHG " . $this->_trid . " NLN 0" . $this->EL;
}
function qry($chl = null) {
return "QRY ".$this->_trid . " ". $this->getIdCode(). " 32".$this->EL.$this->challenger($chl);
}
function challenger($chl) {
return md5($chl.$this->getCode());
}
function out() {
return "OUT" . $this->EL;
}
}
*/