00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef EVENTS_H
00028 #define EVENTS_H
00029
00030 #include <time.h>
00031 #include <string>
00032
00033 #include <libicq2000/constants.h>
00034
00035 #include <libicq2000/ContactList.h>
00036
00037 using std::string;
00038
00039 namespace ICQ2000 {
00040
00041 class Contact;
00042
00047 class Event {
00048 protected:
00052 time_t m_time;
00053
00054 public:
00055 Event();
00056 Event(time_t t);
00057
00058 time_t getTime() const;
00059 void setTime(time_t t);
00060 };
00061
00062
00063
00067 class SocketEvent : public Event {
00068 private:
00069 int m_fd;
00070
00071 public:
00072 SocketEvent(int fd);
00073 virtual ~SocketEvent();
00074
00075 int getSocketHandle() const;
00076
00080 enum Mode {
00081 READ = 1 << 0,
00082 WRITE = 1 << 1,
00083 EXCEPTION = 1 << 2
00084 };
00085 };
00086
00092 class AddSocketHandleEvent : public SocketEvent {
00093 private:
00094 Mode m_mode;
00095
00096 public:
00097 AddSocketHandleEvent(int fd, Mode m);
00098
00099 Mode getMode() const;
00100 bool isRead() const;
00101 bool isWrite() const;
00102 bool isException() const;
00103 };
00104
00110 class RemoveSocketHandleEvent : public SocketEvent {
00111 public:
00112 RemoveSocketHandleEvent(int fd);
00113 };
00114
00115
00116
00121 class ConnectedEvent : public Event {
00122 public:
00123 ConnectedEvent();
00124 };
00125
00126
00127
00133 class DisconnectedEvent : public Event {
00134 public:
00138 enum Reason {
00139 REQUESTED,
00140 FAILED_LOWLEVEL,
00141 FAILED_BADUSERNAME,
00142 FAILED_TURBOING,
00143 FAILED_BADPASSWORD,
00144 FAILED_MISMATCH_PASSWD,
00145 FAILED_DUALLOGIN,
00146 FAILED_UNKNOWN
00147 };
00148
00149 private:
00150 Reason m_reason;
00151
00152 public:
00153 DisconnectedEvent(Reason r);
00154
00155 Reason getReason() const;
00156 };
00157
00158
00159
00163 class LogEvent : public Event {
00164 public:
00168 enum LogType {
00169 WARN,
00170 ERROR,
00171 INFO,
00172 PACKET,
00173 DIRECTPACKET
00174 };
00175
00176 private:
00177 LogType m_type;
00178 string m_msg;
00179
00180 public:
00181 LogEvent(LogType type, const string& msg);
00182
00183 LogType getType() const;
00184 string getMessage() const;
00185 };
00186
00187
00188
00192 class ContactListEvent : public Event {
00193 public:
00197 enum EventType {
00198 StatusChange,
00199 UserInfoChange,
00200 UserAdded,
00201 UserRemoved,
00202 MessageQueueChanged,
00203 ServerBasedContact
00204 };
00205
00206 protected:
00210 Contact *m_contact;
00211
00212 public:
00213 ContactListEvent(Contact* c);
00214 virtual ~ContactListEvent();
00215
00216 Contact* getContact() const;
00217 unsigned int getUIN() const;
00218
00224 virtual EventType getType() const = 0;
00225 };
00226
00230 class UserInfoChangeEvent : public ContactListEvent {
00231 public:
00232 UserInfoChangeEvent(Contact* c);
00233 EventType getType() const;
00234 };
00235
00239 class ServerBasedContactEvent : public ContactListEvent {
00240 public:
00241 ServerBasedContactEvent(Contact *c);
00242 EventType getType() const;
00243 };
00244
00248 class UserAddedEvent : public ContactListEvent {
00249 public:
00250 UserAddedEvent(Contact *c);
00251 EventType getType() const;
00252 };
00253
00257 class UserRemovedEvent : public ContactListEvent {
00258 public:
00259 UserRemovedEvent(Contact *c);
00260 EventType getType() const;
00261 };
00262
00266 class MessageQueueChangedEvent : public ContactListEvent {
00267 public:
00268 MessageQueueChangedEvent(Contact *c);
00269 EventType getType() const;
00270 };
00271
00275 class StatusChangeEvent : public ContactListEvent {
00276 private:
00277 Status m_status;
00278 Status m_old_status;
00279
00280 public:
00281 StatusChangeEvent(Contact* contact, Status status, Status old_status);
00282
00283 EventType getType() const;
00284 Status getStatus() const;
00285 Status getOldStatus() const;
00286 };
00287
00288
00289
00294 class MessageEvent : public Event {
00295 protected:
00297 Contact* m_contact;
00299 bool m_finished;
00301 bool m_delivered;
00303 bool m_direct;
00304
00305 public:
00309 enum MessageType {
00310 Normal,
00311 URL,
00312 SMS,
00313 SMS_Receipt,
00314 AuthReq,
00315 AuthAck,
00316 AwayMessage
00317 };
00318
00319 MessageEvent(Contact* c);
00320 virtual ~MessageEvent();
00321
00327 virtual MessageType getType() const = 0;
00328 Contact* getContact();
00329
00330 bool isFinished() const;
00331 bool isDelivered() const;
00332 bool isDirect() const;
00333
00334 void setFinished(bool f);
00335 void setDelivered(bool f);
00336 void setDirect(bool f);
00337
00338 };
00339
00343 class NormalMessageEvent : public MessageEvent {
00344 private:
00345 string m_message;
00346 bool m_offline, m_multi;
00347 unsigned int m_foreground, m_background;
00348
00349 public:
00350 NormalMessageEvent(Contact* c, const string& msg, bool multi = false);
00351 NormalMessageEvent(Contact* c, const string& msg, time_t t, bool multi);
00352 NormalMessageEvent(Contact* c, const string& msg, unsigned int fg, unsigned int bg);
00353
00354 string getMessage() const;
00355 MessageType getType() const;
00356 unsigned int getSenderUIN() const;
00357 bool isOfflineMessage() const;
00358 bool isMultiParty() const;
00359 unsigned int getForeground() const;
00360 unsigned int getBackground() const;
00361 void setForeground(unsigned int f);
00362 void setBackground(unsigned int b);
00363 };
00364
00368 class URLMessageEvent : public MessageEvent {
00369 private:
00370 string m_message, m_url;
00371 bool m_offline;
00372
00373 public:
00374 URLMessageEvent(Contact* c, const string& msg, const string& url);
00375 URLMessageEvent(Contact* c, const string& msg, const string& url, time_t t);
00376
00377 string getMessage() const;
00378 string getURL() const;
00379 MessageType getType() const;
00380 unsigned int getSenderUIN() const;
00381 bool isOfflineMessage() const;
00382 };
00383
00387 class SMSMessageEvent : public MessageEvent {
00388 private:
00389 string m_message, m_source, m_sender, m_senders_network;
00390 bool m_rcpt;
00391
00392 public:
00393 SMSMessageEvent(Contact* c, const string& msg, bool rcpt);
00394 SMSMessageEvent(Contact* c, const string& msg, const string& source,
00395 const string& senders_network, const string& time);
00396
00397 string getMessage() const;
00398 MessageType getType() const;
00399 string getSource() const;
00400 string getSender() const;
00401 string getSenders_network() const;
00402 bool getRcpt() const;
00403 };
00404
00408 class SMSReceiptEvent : public MessageEvent {
00409 private:
00410 string m_message, m_message_id, m_destination, m_submission_time, m_delivery_time;
00411 bool m_delivered;
00412
00413 public:
00414 SMSReceiptEvent(Contact* c, const string& msg, const string& message_id,
00415 const string& submission_time, const string& delivery_time, bool del);
00416
00417 MessageType getType() const;
00418 string getMessage() const;
00419 string getMessageId() const;
00420 string getDestination() const;
00421 string getSubmissionTime() const;
00422 string getDeliveryTime() const;
00423 bool delivered() const;
00424 };
00425
00429 class AwayMessageEvent : public MessageEvent {
00430 private:
00431 Contact *m_contact;
00432 string m_message;
00433
00434 public:
00435 AwayMessageEvent(Contact *c);
00436
00437 MessageType getType() const;
00438 string getMessage() const;
00439 void setMessage(const string& msg);
00440 };
00441
00445 class AuthReqEvent : public MessageEvent {
00446 private:
00447 string m_nick;
00448 string m_firstname;
00449 string m_lastname;
00450 string m_email;
00451 string m_message;
00452 bool m_offline;
00453
00454 public:
00455 AuthReqEvent(Contact* c, const string& msg);
00456 AuthReqEvent(Contact* c, const string& nick, const string& firstname,
00457 const string& lastname, const string& email,
00458 const string& msg);
00459 AuthReqEvent(Contact* c, const string& nick, const string& firstname,
00460 const string& lastname, const string& email,
00461 const string& msg,time_t time);
00462
00463 string getMessage() const;
00464 string getNick() const;
00465 string getFirstName() const;
00466 string getLastName() const;
00467 string getEmail() const;
00468 MessageType getType() const;
00469 bool isOfflineMessage() const;
00470 unsigned int getSenderUIN() const;
00471 };
00472
00476 class AuthAckEvent : public MessageEvent {
00477 private:
00478 string m_message;
00479 bool m_offline;
00480 bool m_granted;
00481
00482 public:
00483 AuthAckEvent(Contact* c, bool granted);
00484 AuthAckEvent(Contact* c, bool granted, time_t time);
00485 AuthAckEvent(Contact* c, const string& msg, bool granted);
00486 AuthAckEvent(Contact* c, const string& msg, bool granted, time_t time);
00487
00488 string getMessage() const;
00489 MessageType getType() const;
00490 bool isOfflineMessage() const;
00491 bool isGranted() const;
00492 unsigned int getSenderUIN() const;
00493 };
00494
00495
00496
00500 class MyStatusChangeEvent : public Event {
00501 private:
00502 Status m_status;
00503 bool m_invisible;
00504
00505 public:
00506 MyStatusChangeEvent(Status s, bool inv = false);
00507
00508 Status getStatus() const;
00509 bool getInvisible() const;
00510 };
00511
00512
00513
00517 class SearchResultEvent : public Event {
00518 public:
00519 enum SearchType {
00520 ShortWhitepage,
00521 FullWhitepage,
00522 UIN
00523 };
00524
00525 private:
00526 bool m_finished, m_expired;
00527 SearchType m_searchtype;
00528 ContactList m_clist;
00529 Contact *m_last_contact;
00530 unsigned int m_more_results;
00531
00532 public:
00533 SearchResultEvent(SearchType t);
00534
00535 SearchType getSearchType() const;
00536 ContactList& getContactList();
00537 Contact* getLastContactAdded() const;
00538 void setLastContactAdded(Contact *c);
00539 unsigned int getNumberMoreResults() const;
00540
00541 bool isFinished() const;
00542 void setFinished(bool b);
00543 bool isExpired() const;
00544 void setExpired(bool b);
00545 void setNumberMoreResults(unsigned int m);
00546 };
00547
00548
00549
00553 class NewUINEvent : public Event {
00554 private:
00555 unsigned int m_uin;
00556 bool m_success;
00557
00558 public:
00559 NewUINEvent(unsigned int uin, bool success=true);
00560 unsigned int getUIN() const;
00561 bool isSuccess() const;
00562 };
00563
00567 class RateInfoChangeEvent : public Event {
00568 public:
00572 enum RateClass {
00573 RATE_CHANGE=1,
00574 RATE_WARNING,
00575 RATE_LIMIT,
00576 RATE_LIMIT_CLEARED
00577 };
00578
00579 private:
00580 unsigned short m_code;
00581 unsigned short m_rateclass;
00582 unsigned int m_windowsize;
00583 unsigned int m_clear;
00584 unsigned int m_alert;
00585 unsigned int m_limit;
00586 unsigned int m_disconnect;
00587 unsigned int m_currentavg;
00588 unsigned int m_maxavg;
00589
00590 public:
00591 RateInfoChangeEvent(unsigned short code, unsigned short rateclass,
00592 unsigned int windowsize,unsigned int clear,
00593 unsigned int alert,unsigned int limit,
00594 unsigned int disconnect,unsigned int currentavg,
00595 unsigned int maxavg);
00596
00598 unsigned short getCode() const { return m_code; }
00600 unsigned short getRateClass() const { return m_rateclass; }
00602 unsigned int getWindowSize() const { return m_windowsize; }
00604 unsigned int getClear() const { return m_clear; }
00606 unsigned int getAlert() const { return m_alert; }
00608 unsigned int getLimit() const { return m_limit; }
00610 unsigned int getDisconnect() const { return m_disconnect; }
00612 unsigned int getCurrentAvg() const { return m_currentavg; }
00614 unsigned int getMaxAvg() const { return m_maxavg; }
00615 };
00616
00617 }
00618
00619 #endif