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
00043
00044
00045
00046
00051 class Event {
00052 protected:
00056 time_t m_time;
00057
00058 public:
00059 Event();
00060 Event(time_t t);
00061
00062 time_t getTime() const;
00063 void setTime(time_t t);
00064 };
00065
00066
00067
00068
00069
00073 class SocketEvent : public Event {
00074 private:
00075 int m_fd;
00076
00077 public:
00078 SocketEvent(int fd);
00079 virtual ~SocketEvent();
00080
00081 int getSocketHandle() const;
00082
00086 enum Mode {
00087 READ = 1 << 0,
00088 WRITE = 1 << 1,
00089 EXCEPTION = 1 << 2
00090 };
00091 };
00092
00098 class AddSocketHandleEvent : public SocketEvent {
00099 private:
00100 Mode m_mode;
00101
00102 public:
00103 AddSocketHandleEvent(int fd, Mode m);
00104
00105 Mode getMode() const;
00106 bool isRead() const;
00107 bool isWrite() const;
00108 bool isException() const;
00109 };
00110
00116 class RemoveSocketHandleEvent : public SocketEvent {
00117 public:
00118 RemoveSocketHandleEvent(int fd);
00119 };
00120
00121
00122
00123
00124
00128 class ConnectingEvent : public Event {
00129 public:
00130 ConnectingEvent();
00131 };
00132
00133
00134
00135
00136
00141 class ConnectedEvent : public Event {
00142 public:
00143 ConnectedEvent();
00144 };
00145
00146
00147
00148
00149
00155 class DisconnectedEvent : public Event {
00156 public:
00160 enum Reason {
00161 REQUESTED,
00162 FAILED_LOWLEVEL,
00163 FAILED_BADUSERNAME,
00164 FAILED_TURBOING,
00165 FAILED_BADPASSWORD,
00166 FAILED_MISMATCH_PASSWD,
00167 FAILED_DUALLOGIN,
00168 FAILED_UNKNOWN
00169 };
00170
00171 private:
00172 Reason m_reason;
00173
00174 public:
00175 DisconnectedEvent(Reason r);
00176
00177 Reason getReason() const;
00178 };
00179
00180
00181
00182
00183
00187 class LogEvent : public Event {
00188 public:
00192 enum LogType {
00193 WARN,
00194 ERROR,
00195 INFO,
00196 PACKET,
00197 DIRECTPACKET
00198 };
00199
00200 private:
00201 LogType m_type;
00202 string m_msg;
00203
00204 public:
00205 LogEvent(LogType type, const string& msg);
00206
00207 LogType getType() const;
00208 string getMessage() const;
00209 };
00210
00211
00212
00213
00214
00218 class ContactListEvent : public Event {
00219 public:
00223 enum EventType {
00224 UserAdded,
00225 UserRemoved
00226 };
00227
00228 protected:
00232 ContactRef m_contact;
00233
00234 public:
00235 ContactListEvent(ContactRef c);
00236 virtual ~ContactListEvent();
00237
00238 ContactRef getContact() const;
00239 unsigned int getUIN() const;
00240
00246 virtual EventType getType() const = 0;
00247 };
00248
00252 class UserAddedEvent : public ContactListEvent {
00253 public:
00254 UserAddedEvent(ContactRef c);
00255 EventType getType() const;
00256 };
00257
00261 class UserRemovedEvent : public ContactListEvent {
00262 public:
00263 UserRemovedEvent(ContactRef c);
00264 EventType getType() const;
00265 };
00266
00267
00268
00269
00270
00274 class ContactEvent : public Event {
00275 public:
00279 enum EventType {
00280 StatusChange,
00281 UserInfoChange,
00282 };
00283
00284 protected:
00288 ContactRef m_contact;
00289
00290 public:
00291 ContactEvent(ContactRef c);
00292 virtual ~ContactEvent();
00293
00294 ContactRef getContact() const;
00295 unsigned int getUIN() const;
00296
00302 virtual EventType getType() const = 0;
00303 };
00304
00308 class UserInfoChangeEvent : public ContactEvent {
00309 private:
00310 bool m_is_transient_detail;
00311 public:
00312 UserInfoChangeEvent(ContactRef c, bool is_transient_detail);
00313 EventType getType() const;
00314 bool isTransientDetail() const;
00315 };
00316
00320 class StatusChangeEvent : public ContactEvent {
00321 private:
00322 Status m_status;
00323 Status m_old_status;
00324
00325 public:
00326 StatusChangeEvent(ContactRef contact, Status status, Status old_status);
00327
00328 EventType getType() const;
00329 Status getStatus() const;
00330 Status getOldStatus() const;
00331 };
00332
00333
00334
00335
00336
00341 class MessageEvent : public Event {
00342 public:
00346 enum MessageType {
00347 Normal,
00348 URL,
00349 SMS,
00350 SMS_Receipt,
00351 AuthReq,
00352 AuthAck,
00353 AwayMessage,
00354 EmailEx,
00355 UserAdd,
00356 Email,
00357 WebPager
00358 };
00359
00360 enum DeliveryFailureReason {
00361 Failed,
00362 Failed_NotConnected,
00363 Failed_ClientNotCapable,
00364 Failed_Denied,
00365 Failed_Ignored,
00366 Failed_Occupied,
00367 Failed_DND,
00368 Failed_SMTP
00369 };
00370
00371 protected:
00373 ContactRef m_contact;
00375 bool m_finished;
00377 bool m_delivered;
00379 bool m_direct;
00380
00381 DeliveryFailureReason m_failure_reason;
00382
00383 public:
00384 MessageEvent(ContactRef c);
00385 virtual ~MessageEvent();
00386
00392 virtual MessageType getType() const = 0;
00393 ContactRef getContact();
00394
00395 bool isFinished() const;
00396 bool isDelivered() const;
00397 bool isDirect() const;
00398
00399 void setFinished(bool f);
00400 void setDelivered(bool f);
00401 void setDirect(bool f);
00402
00403 DeliveryFailureReason getDeliveryFailureReason() const;
00404 void setDeliveryFailureReason(DeliveryFailureReason d);
00405 };
00406
00410 class ICQMessageEvent : public MessageEvent {
00411 private:
00412 bool m_urgent, m_tocontactlist, m_offline;
00413 std::string m_away_message;
00414
00415 public:
00416 ICQMessageEvent(ContactRef c);
00417
00418 bool isUrgent() const;
00419 void setUrgent(bool b);
00420 bool isToContactList() const;
00421 void setToContactList(bool b);
00422 bool isOfflineMessage() const;
00423 void setOfflineMessage(bool b);
00424 unsigned int getSenderUIN() const;
00425 std::string getAwayMessage() const;
00426 void setAwayMessage(const std::string& msg);
00427
00428 virtual ICQMessageEvent* copy() const = 0;
00429 };
00430
00434 class NormalMessageEvent : public ICQMessageEvent {
00435 private:
00436 string m_message;
00437 bool m_multi;
00438 unsigned int m_foreground, m_background;
00439
00440 public:
00441 NormalMessageEvent(ContactRef c, const string& msg, bool multi = false);
00442 NormalMessageEvent(ContactRef c, const string& msg, time_t t, bool multi);
00443 NormalMessageEvent(ContactRef c, const string& msg, unsigned int fg, unsigned int bg);
00444
00445 string getMessage() const;
00446 MessageType getType() const;
00447 bool isMultiParty() const;
00448 unsigned int getForeground() const;
00449 unsigned int getBackground() const;
00450 void setForeground(unsigned int f);
00451 void setBackground(unsigned int b);
00452
00453 ICQMessageEvent* copy() const;
00454 };
00455
00459 class URLMessageEvent : public ICQMessageEvent {
00460 private:
00461 string m_message, m_url;
00462
00463 public:
00464 URLMessageEvent(ContactRef c, const string& msg, const string& url);
00465 URLMessageEvent(ContactRef c, const string& msg, const string& url, time_t t);
00466
00467 string getMessage() const;
00468 string getURL() const;
00469 MessageType getType() const;
00470
00471 ICQMessageEvent* copy() const;
00472 };
00473
00477 class SMSMessageEvent : public MessageEvent {
00478 private:
00479 string m_message, m_source, m_sender, m_senders_network;
00480 string m_smtp_from, m_smtp_to, m_smtp_subject;
00481 bool m_rcpt;
00482
00483 public:
00484 SMSMessageEvent(ContactRef c, const string& msg, bool rcpt);
00485 SMSMessageEvent(ContactRef c, const string& msg, const string& source,
00486 const string& senders_network, const string& time);
00487
00488 string getMessage() const;
00489 MessageType getType() const;
00490 string getSource() const;
00491 string getSender() const;
00492 string getSenders_network() const;
00493 bool getRcpt() const;
00494
00495 void setSMTPFrom(const string& from);
00496 string getSMTPFrom() const;
00497
00498 void setSMTPTo(const string& to);
00499 string getSMTPTo() const;
00500
00501 void setSMTPSubject(const string& subj);
00502 string getSMTPSubject() const;
00503 };
00504
00508 class SMSReceiptEvent : public MessageEvent {
00509 private:
00510 string m_message, m_message_id, m_destination, m_submission_time, m_delivery_time;
00511 bool m_delivered;
00512
00513 public:
00514 SMSReceiptEvent(ContactRef c, const string& msg, const string& message_id,
00515 const string& submission_time, const string& delivery_time, bool del);
00516
00517 MessageType getType() const;
00518 string getMessage() const;
00519 string getMessageId() const;
00520 string getDestination() const;
00521 string getSubmissionTime() const;
00522 string getDeliveryTime() const;
00523 bool delivered() const;
00524 };
00525
00533 class AwayMessageEvent : public ICQMessageEvent {
00534 public:
00535 AwayMessageEvent(ContactRef c);
00536
00537 MessageType getType() const;
00538
00539 ICQMessageEvent* copy() const;
00540 };
00541
00545 class AuthReqEvent : public ICQMessageEvent {
00546 private:
00547 string m_message;
00548
00549 public:
00550 AuthReqEvent(ContactRef c, const string& msg);
00551 AuthReqEvent(ContactRef c, const string& msg, time_t time);
00552
00553 string getMessage() const;
00554 MessageType getType() const;
00555
00556 ICQMessageEvent* copy() const;
00557 };
00558
00562 class AuthAckEvent : public ICQMessageEvent {
00563 private:
00564 string m_message;
00565 bool m_granted;
00566
00567 public:
00568 AuthAckEvent(ContactRef c, bool granted);
00569 AuthAckEvent(ContactRef c, bool granted, time_t time);
00570 AuthAckEvent(ContactRef c, const string& msg, bool granted);
00571 AuthAckEvent(ContactRef c, const string& msg, bool granted, time_t time);
00572
00573 string getMessage() const;
00574 MessageType getType() const;
00575 bool isGranted() const;
00576
00577 ICQMessageEvent* copy() const;
00578 };
00579
00583 class EmailExEvent : public MessageEvent {
00584 private:
00585 string m_sender, m_email, m_message;
00586
00587 public:
00588 EmailExEvent(ContactRef c, const string &email, const string &sender, const string &msg);
00589
00590 string getMessage() const;
00591 string getEmail() const;
00592 string getSender() const;
00593
00594 MessageType getType() const;
00595 unsigned int getSenderUIN() const;
00596 };
00597
00601 class WebPagerEvent : public MessageEvent {
00602 private:
00603 string m_sender, m_email, m_message;
00604
00605 public:
00606 WebPagerEvent(ContactRef c, const string& email, const string& sender, const string& msg);
00607
00608 string getMessage() const;
00609 string getEmail() const;
00610 string getSender() const;
00611
00612 MessageType getType() const;
00613 };
00614
00618 class UserAddEvent : public ICQMessageEvent {
00619 public:
00620 UserAddEvent(ContactRef c);
00621
00622 MessageType getType() const;
00623 unsigned int getSenderUIN() const;
00624
00625 ICQMessageEvent* copy() const;
00626 };
00627
00631 class EmailMessageEvent : public MessageEvent {
00632 private:
00633 string m_message;
00634
00635 public:
00636 EmailMessageEvent(ContactRef c, const string &msg);
00637
00638 string getMessage() const;
00639
00640 MessageType getType() const;
00641 };
00642
00643
00644
00645
00646
00650 class SearchResultEvent : public Event {
00651 public:
00652 enum SearchType {
00653 ShortWhitepage,
00654 FullWhitepage,
00655 UIN,
00656 Keyword
00657 };
00658
00659 private:
00660 bool m_finished, m_expired;
00661 SearchType m_searchtype;
00662 ContactList m_clist;
00663 ContactRef m_last_contact;
00664 unsigned int m_more_results;
00665
00666 public:
00667 SearchResultEvent(SearchType t);
00668
00669 SearchType getSearchType() const;
00670 ContactList& getContactList();
00671 ContactRef getLastContactAdded() const;
00672 void setLastContactAdded(ContactRef c);
00673 unsigned int getNumberMoreResults() const;
00674
00675 bool isFinished() const;
00676 void setFinished(bool b);
00677 bool isExpired() const;
00678 void setExpired(bool b);
00679 void setNumberMoreResults(unsigned int m);
00680 };
00681
00685 class ServerBasedContactEvent : public Event {
00686 private:
00687 ContactList m_clist;
00688 public:
00689 ServerBasedContactEvent(const ContactList& l);
00690 ContactList& getContactList();
00691 };
00692
00693
00694
00695
00696
00700 class NewUINEvent : public Event {
00701 private:
00702 unsigned int m_uin;
00703 bool m_success;
00704
00705 public:
00706 NewUINEvent(unsigned int uin, bool success=true);
00707 unsigned int getUIN() const;
00708 bool isSuccess() const;
00709 };
00710
00714 class RateInfoChangeEvent : public Event {
00715 public:
00719 enum RateClass {
00720 RATE_CHANGE=1,
00721 RATE_WARNING,
00722 RATE_LIMIT,
00723 RATE_LIMIT_CLEARED
00724 };
00725
00726 private:
00727 unsigned short m_code;
00728 unsigned short m_rateclass;
00729 unsigned int m_windowsize;
00730 unsigned int m_clear;
00731 unsigned int m_alert;
00732 unsigned int m_limit;
00733 unsigned int m_disconnect;
00734 unsigned int m_currentavg;
00735 unsigned int m_maxavg;
00736
00737 public:
00738 RateInfoChangeEvent(unsigned short code, unsigned short rateclass,
00739 unsigned int windowsize,unsigned int clear,
00740 unsigned int alert,unsigned int limit,
00741 unsigned int disconnect,unsigned int currentavg,
00742 unsigned int maxavg);
00743
00745 unsigned short getCode() const { return m_code; }
00747 unsigned short getRateClass() const { return m_rateclass; }
00749 unsigned int getWindowSize() const { return m_windowsize; }
00751 unsigned int getClear() const { return m_clear; }
00753 unsigned int getAlert() const { return m_alert; }
00755 unsigned int getLimit() const { return m_limit; }
00757 unsigned int getDisconnect() const { return m_disconnect; }
00759 unsigned int getCurrentAvg() const { return m_currentavg; }
00761 unsigned int getMaxAvg() const { return m_maxavg; }
00762 };
00763
00764 }
00765
00766 #endif