diff options
author | George Hazan <george.hazan@gmail.com> | 2014-09-18 21:52:10 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-09-18 21:52:10 +0000 |
commit | 6d932bfaf11e4699355fedc45e28b353b8877130 (patch) | |
tree | 78d3f6741cf9762d2c6b97ed1f5bc472e850e15f /protocols/WhatsApp/src/proto.h | |
parent | 4dd774d667df90583315c04696537b6397f6fc02 (diff) |
merge into trunk
git-svn-id: http://svn.miranda-ng.org/main/trunk@10515 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/proto.h')
-rw-r--r-- | protocols/WhatsApp/src/proto.h | 260 |
1 files changed, 129 insertions, 131 deletions
diff --git a/protocols/WhatsApp/src/proto.h b/protocols/WhatsApp/src/proto.h index aa8483bd02..8963735320 100644 --- a/protocols/WhatsApp/src/proto.h +++ b/protocols/WhatsApp/src/proto.h @@ -9,25 +9,25 @@ public: WhatsAppProto(const char *proto_name, const TCHAR *username);
~WhatsAppProto( );
- inline const char* ModuleName( ) const
+ inline const char* ModuleName() const
{
return m_szModuleName;
}
- inline bool isOnline( )
+ inline bool isOnline()
{
- return ( m_iStatus != ID_STATUS_OFFLINE && m_iStatus != ID_STATUS_CONNECTING &&
- connection != NULL );
+ return (m_iStatus != ID_STATUS_OFFLINE && m_iStatus != ID_STATUS_CONNECTING &&
+ connection != NULL);
}
- inline bool isOffline( )
+ inline bool isOffline()
{
- return ( m_iStatus == ID_STATUS_OFFLINE );
+ return (m_iStatus == ID_STATUS_OFFLINE);
}
- inline bool isInvisible( )
+ inline bool isInvisible()
{
- return ( m_iStatus == ID_STATUS_INVISIBLE );
+ return (m_iStatus == ID_STATUS_INVISIBLE);
}
//PROTO_INTERFACE
@@ -35,176 +35,174 @@ public: virtual MCONTACT __cdecl AddToList(int flags, PROTOSEARCHRESULT* psr);
virtual MCONTACT __cdecl AddToListByEvent(int flags, int iContact, HANDLE hDbEvent) { return NULL; }
- virtual int __cdecl Authorize( HANDLE hDbEvent );
- virtual int __cdecl AuthDeny( HANDLE hDbEvent, const PROTOCHAR* szReason ) { return 1; }
- virtual int __cdecl AuthRecv(MCONTACT hContact, PROTORECVEVENT* ) { return 1; }
- virtual int __cdecl AuthRequest(MCONTACT hContact, const PROTOCHAR* szMessage );
+ virtual int __cdecl Authorize(HANDLE hDbEvent);
+ virtual int __cdecl AuthDeny(HANDLE hDbEvent, const PROTOCHAR* szReason) { return 1; }
+ virtual int __cdecl AuthRecv(MCONTACT hContact, PROTORECVEVENT*) { return 1; }
+ virtual int __cdecl AuthRequest(MCONTACT hContact, const PROTOCHAR* szMessage);
- virtual HANDLE __cdecl FileAllow(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szPath ) { return NULL; }
- virtual int __cdecl FileCancel(MCONTACT hContact, HANDLE hTransfer ) { return 1; }
- virtual int __cdecl FileDeny(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szReason ) { return 1; }
- virtual int __cdecl FileResume( HANDLE hTransfer, int* action, const PROTOCHAR** szFilename ) { return 1; }
+ virtual HANDLE __cdecl FileAllow(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szPath) { return NULL; }
+ virtual int __cdecl FileCancel(MCONTACT hContact, HANDLE hTransfer) { return 1; }
+ virtual int __cdecl FileDeny(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szReason) { return 1; }
+ virtual int __cdecl FileResume(HANDLE hTransfer, int* action, const PROTOCHAR** szFilename) { return 1; }
- virtual DWORD_PTR __cdecl GetCaps( int type, MCONTACT hContact = NULL );
- virtual int __cdecl GetInfo(MCONTACT hContact, int infoType ) { return 1; }
+ virtual DWORD_PTR __cdecl GetCaps(int type, MCONTACT hContact = NULL);
+ virtual int __cdecl GetInfo(MCONTACT hContact, int infoType) { return 1; }
- virtual HANDLE __cdecl SearchBasic( const PROTOCHAR* id );
- virtual HANDLE __cdecl SearchByEmail( const PROTOCHAR* email ) { return NULL; }
- virtual HANDLE __cdecl SearchByName( const PROTOCHAR* nick, const PROTOCHAR* firstName, const PROTOCHAR* lastName ) { return NULL; }
- virtual HWND __cdecl SearchAdvanced( HWND owner ) { return NULL; }
- virtual HWND __cdecl CreateExtendedSearchUI( HWND owner ) { return NULL; }
+ virtual HANDLE __cdecl SearchBasic(const PROTOCHAR* id);
+ virtual HANDLE __cdecl SearchByEmail(const PROTOCHAR* email) { return NULL; }
+ virtual HANDLE __cdecl SearchByName(const PROTOCHAR* nick, const PROTOCHAR* firstName, const PROTOCHAR* lastName) { return NULL; }
+ virtual HWND __cdecl SearchAdvanced(HWND owner) { return NULL; }
+ virtual HWND __cdecl CreateExtendedSearchUI(HWND owner) { return NULL; }
- virtual int __cdecl RecvContacts(MCONTACT hContact, PROTORECVEVENT* ) { return 1; }
- virtual int __cdecl RecvFile(MCONTACT hContact, PROTOFILEEVENT* ) { return 1; }
- virtual int __cdecl RecvMsg(MCONTACT hContact, PROTORECVEVENT* );
- virtual int __cdecl RecvUrl(MCONTACT hContact, PROTORECVEVENT* ) { return 1; }
+ virtual int __cdecl RecvContacts(MCONTACT hContact, PROTORECVEVENT*) { return 1; }
+ virtual int __cdecl RecvFile(MCONTACT hContact, PROTOFILEEVENT*) { return 1; }
+ virtual int __cdecl RecvMsg(MCONTACT hContact, PROTORECVEVENT*);
+ virtual int __cdecl RecvUrl(MCONTACT hContact, PROTORECVEVENT*) { return 1; }
virtual int __cdecl SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT *hContactsList) { return 1; }
- virtual HANDLE __cdecl SendFile(MCONTACT hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles ) { return NULL; }
- virtual int __cdecl SendMsg(MCONTACT hContact, int flags, const char* msg );
- virtual int __cdecl SendUrl(MCONTACT hContact, int flags, const char* url ) { return 1; }
+ virtual HANDLE __cdecl SendFile(MCONTACT hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles) { return NULL; }
+ virtual int __cdecl SendMsg(MCONTACT hContact, int flags, const char* msg);
+ virtual int __cdecl SendUrl(MCONTACT hContact, int flags, const char* url) { return 1; }
- virtual int __cdecl SetApparentMode(MCONTACT hContact, int mode ) { return 1; }
- virtual int __cdecl SetStatus( int iNewStatus );
+ virtual int __cdecl SetApparentMode(MCONTACT hContact, int mode) { return 1; }
+ virtual int __cdecl SetStatus(int iNewStatus);
- virtual HANDLE __cdecl GetAwayMsg(MCONTACT hContact ) { return NULL; }
- virtual int __cdecl RecvAwayMsg(MCONTACT hContact, int mode, PROTORECVEVENT* evt ) { return 1; }
- virtual int __cdecl SendAwayMsg(MCONTACT hContact, HANDLE hProcess, const char* msg ) { return 1; }
- virtual int __cdecl SetAwayMsg( int iStatus, const PROTOCHAR* msg ) { return 1; }
+ virtual HANDLE __cdecl GetAwayMsg(MCONTACT hContact) { return NULL; }
+ virtual int __cdecl RecvAwayMsg(MCONTACT hContact, int mode, PROTORECVEVENT* evt) { return 1; }
+ virtual int __cdecl SendAwayMsg(MCONTACT hContact, HANDLE hProcess, const char* msg) { return 1; }
+ virtual int __cdecl SetAwayMsg(int iStatus, const PROTOCHAR* msg) { return 1; }
- virtual int __cdecl UserIsTyping(MCONTACT hContact, int type );
+ virtual int __cdecl UserIsTyping(MCONTACT hContact, int type);
- virtual int __cdecl OnEvent( PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam ) { return 1; }
+ virtual int __cdecl OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam) { return 1; }
////////////////////////
- // Services
- INT_PTR __cdecl SvcCreateAccMgrUI( WPARAM, LPARAM);
+ // Services
+ INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM);
INT_PTR __cdecl OnJoinChat(WPARAM, LPARAM);
INT_PTR __cdecl OnLeaveChat(WPARAM, LPARAM);
- INT_PTR __cdecl OnCreateGroup(WPARAM,LPARAM);
+ INT_PTR __cdecl OnCreateGroup(WPARAM, LPARAM);
int __cdecl OnOptionsInit(WPARAM, LPARAM);
int __cdecl OnModulesLoaded(WPARAM, LPARAM);
-
+
int __cdecl RefreshBuddyList(WPARAM, LPARAM);
- int __cdecl RequestFriendship(WPARAM, LPARAM);
-
- // Events
- int __cdecl OnBuildStatusMenu(WPARAM,LPARAM);
- int __cdecl OnChatOutgoing(WPARAM,LPARAM);
- int __cdecl OnPrebuildContactMenu(WPARAM,LPARAM);
-
- INT_PTR __cdecl OnAddContactToGroup(WPARAM, LPARAM, LPARAM);
- INT_PTR __cdecl OnRemoveContactFromGroup(WPARAM, LPARAM, LPARAM);
- INT_PTR __cdecl OnChangeGroupSubject(WPARAM, LPARAM);
- INT_PTR __cdecl OnLeaveGroup(WPARAM, LPARAM);
-
- // Loops
- bool NegotiateConnection();
- void __cdecl stayConnectedLoop(void*);
- void __cdecl sentinelLoop(void*);
-
- // Processing Threads
- void __cdecl ProcessBuddyList(void*);
- void __cdecl SearchAckThread(void*);
-
- // Worker Threads
- void __cdecl ChangeStatus(void*);
- void __cdecl SendMsgWorker(void*);
- void __cdecl RecvMsgWorker(void*);
- void __cdecl SendTypingWorker(void*);
- void __cdecl SendGetGroupInfoWorker(void*);
- void __cdecl SendSetGroupNameWorker(void*);
- void __cdecl SendCreateGroupWorker(void*);
-
- // Contacts handling
- MCONTACT AddToContactList(const std::string& jid, BYTE type = 0, bool dont_check = false,
- const char *new_name = NULL, bool isChatRoom = false, bool isHidden = false);
+ int __cdecl RequestFriendship(WPARAM, LPARAM);
+
+ // Events
+ int __cdecl OnBuildStatusMenu(WPARAM, LPARAM);
+ int __cdecl OnChatOutgoing(WPARAM, LPARAM);
+ int __cdecl OnPrebuildContactMenu(WPARAM, LPARAM);
+
+ INT_PTR __cdecl OnAddContactToGroup(WPARAM, LPARAM, LPARAM);
+ INT_PTR __cdecl OnRemoveContactFromGroup(WPARAM, LPARAM, LPARAM);
+ INT_PTR __cdecl OnChangeGroupSubject(WPARAM, LPARAM);
+ INT_PTR __cdecl OnLeaveGroup(WPARAM, LPARAM);
+
+ // Loops
+ bool NegotiateConnection();
+ void __cdecl stayConnectedLoop(void*);
+ void __cdecl sentinelLoop(void*);
+
+ // Processing Threads
+ void __cdecl ProcessBuddyList(void*);
+ void __cdecl SearchAckThread(void*);
+
+ // Worker Threads
+ void __cdecl ChangeStatus(void*);
+ void __cdecl SendMsgWorker(void*);
+ void __cdecl RecvMsgWorker(void*);
+ void __cdecl SendTypingWorker(void*);
+ void __cdecl SendGetGroupInfoWorker(void*);
+ void __cdecl SendSetGroupNameWorker(void*);
+ void __cdecl SendCreateGroupWorker(void*);
+
+ // Contacts handling
+ MCONTACT AddToContactList(const std::string &jid, BYTE type = 0, bool dont_check = false,
+ const char *new_name = NULL, bool isChatRoom = false, bool isHidden = false);
bool IsMyContact(MCONTACT hContact, bool include_chat = false);
MCONTACT ContactIDToHContact(const std::string&);
- void SetAllContactStatuses(int status, bool reset_client = false);
- void UpdateStatusMsg(MCONTACT hContact);
- string GetContactDisplayName(MCONTACT hContact);
- string GetContactDisplayName(const string& jid);
- void InitContactMenus();
- void HandleReceiveGroups(const std::vector<string>& groups, bool isOwned);
-
+ void SetAllContactStatuses(int status, bool reset_client = false);
+ void UpdateStatusMsg(MCONTACT hContact);
+ TCHAR* GetContactDisplayName(const string &jid);
+ void InitContactMenus();
+ void HandleReceiveGroups(const std::vector<string> &groups, bool isOwned);
+
bool IsGroupChat(MCONTACT hC, bool checkIsAdmin = false)
- {
+ {
return getByte(hC, "SimpleChatRoom", 0) > (checkIsAdmin ? 1 : 0);
- }
+ }
- // Registration
- string Register(int state, string cc, string number, string code);
+ // Registration
+ string Register(int state, const string &cc, const string &number, const string &code);
- // Helpers
- std::tstring GetAvatarFolder();
- void ToggleStatusMenuItems( BOOL bEnable );
- string TranslateStr(const char* str, ...);
+ // Helpers
+ std::tstring GetAvatarFolder();
+ void ToggleStatusMenuItems(BOOL bEnable);
- // Handles, Locks
+ // Handles, Locks
HGENMENU m_hMenuRoot;
HANDLE m_hMenuCreateGroup;
- HANDLE signon_lock_;
- HANDLE log_lock_;
- HANDLE update_loop_lock_;
+ HANDLE signon_lock_;
+ HANDLE log_lock_;
+ HANDLE update_loop_lock_;
- std::tstring def_avatar_folder_;
+ std::tstring def_avatar_folder_;
- WASocketConnection* conn;
- WAConnection* connection;
- Mutex connMutex;
- int lastPongTime;
+ WASocketConnection* conn;
+ WAConnection* connection;
+ Mutex connMutex;
+ int lastPongTime;
- std::vector<unsigned char>* challenge;
- int msgId;
- int msgIdHeader;
- string phoneNumber;
- string jid;
- string nick;
+ std::vector<unsigned char>* challenge;
+ int msgId;
+ int msgIdHeader;
+ string phoneNumber;
+ string jid;
+ string nick;
std::map<string, MCONTACT> hContactByJid;
map<MCONTACT, map<MCONTACT, bool>> isMemberByGroupContact;
- // WhatsApp Events
- virtual void onMessageForMe(FMessage* paramFMessage, bool paramBoolean);
- virtual void onMessageStatusUpdate(FMessage* paramFMessage);
- virtual void onMessageError(FMessage* message, int paramInt) { debugLogA(""); }
- virtual void onPing(const std::string& id) throw (WAException);
- virtual void onPingResponseReceived() { debugLogA(""); }
- virtual void onAvailable(const std::string& paramString, bool paramBoolean);
- virtual void onClientConfigReceived(const std::string& paramString) { debugLogA(""); }
- virtual void onLastSeen(const std::string& paramString1, int paramInt, std::string* paramString2);
- virtual void onIsTyping(const std::string& paramString, bool paramBoolean);
- virtual void onAccountChange(int paramInt, time_t expire_date) { debugLogA(""); }
- virtual void onPrivacyBlockListAdd(const std::string& paramString) { debugLogA(""); }
- virtual void onPrivacyBlockListClear() { debugLogA(""); }
- virtual void onDirty(const std::map<string,string>& paramHashtable) { debugLogA(""); }
- virtual void onDirtyResponse(int paramHashtable) { debugLogA(""); }
- virtual void onRelayRequest(const std::string& paramString1, int paramInt, const std::string& paramString2) { debugLogA(""); }
- virtual void onSendGetPictureIds(std::map<string,string>* ids);
- virtual void onSendGetPicture(const std::string& jid, const std::vector<unsigned char>& data, const std::string& oldId, const std::string& newId);
- virtual void onPictureChanged(const std::string& from, const std::string& author, bool set);
- virtual void onDeleteAccount(bool result) { debugLogA(""); }
+ // WhatsApp Events
+ virtual void onMessageForMe(FMessage* paramFMessage, bool paramBoolean);
+ virtual void onMessageStatusUpdate(FMessage* paramFMessage);
+ virtual void onMessageError(FMessage* message, int paramInt) { ; }
+ virtual void onPing(const std::string& id) throw (WAException);
+ virtual void onPingResponseReceived() { }
+ virtual void onAvailable(const std::string& paramString, bool paramBoolean);
+ virtual void onClientConfigReceived(const std::string& paramString) { }
+ virtual void onLastSeen(const std::string& paramString1, int paramInt, std::string* paramString2);
+ virtual void onIsTyping(const std::string& paramString, bool paramBoolean);
+ virtual void onAccountChange(int paramInt, time_t expire_date) { }
+ virtual void onPrivacyBlockListAdd(const std::string& paramString) { }
+ virtual void onPrivacyBlockListClear() { }
+ virtual void onDirty(const std::map<string, string>& paramHashtable) { }
+ virtual void onDirtyResponse(int paramHashtable) { }
+ virtual void onRelayRequest(const std::string& paramString1, int paramInt, const std::string& paramString2) { }
+ virtual void onSendGetPictureIds(std::map<string, string>* ids);
+ virtual void onSendGetPicture(const std::string& jid, const std::vector<unsigned char>& data, const std::string& oldId, const std::string& newId);
+ virtual void onPictureChanged(const std::string& from, const std::string& author, bool set);
+ virtual void onDeleteAccount(bool result) { }
virtual void onGroupAddUser(const std::string& paramString1, const std::string& paramString2);
virtual void onGroupRemoveUser(const std::string& paramString1, const std::string& paramString2);
virtual void onGroupNewSubject(const std::string& from, const std::string& author, const std::string& newSubject, int paramInt);
- virtual void onServerProperties(std::map<std::string, std::string>* nameValueMap) { debugLogA(""); }
+ virtual void onServerProperties(std::map<std::string, std::string>* nameValueMap) { }
virtual void onGroupCreated(const std::string& paramString1, const std::string& paramString2);
virtual void onGroupInfo(const std::string& paramString1, const std::string& paramString2, const std::string& paramString3, const std::string& paramString4, int paramInt1, int paramInt2);
virtual void onGroupInfoFromList(const std::string& paramString1, const std::string& paramString2, const std::string& paramString3, const std::string& paramString4, int paramInt1, int paramInt2);
virtual void onOwningGroups(const std::vector<string>& paramVector);
- virtual void onSetSubject(const std::string& paramString) { debugLogA(""); }
- virtual void onAddGroupParticipants(const std::string& paramString, const std::vector<string>& paramVector, int paramHashtable) { debugLogA(""); }
- virtual void onRemoveGroupParticipants(const std::string& paramString, const std::vector<string>& paramVector, int paramHashtable) { debugLogA(""); }
+ virtual void onSetSubject(const std::string& paramString) { }
+ virtual void onAddGroupParticipants(const std::string& paramString, const std::vector<string>& paramVector, int paramHashtable) { }
+ virtual void onRemoveGroupParticipants(const std::string& paramString, const std::vector<string>& paramVector, int paramHashtable) { }
virtual void onGetParticipants(const std::string& gjid, const std::vector<string>& participants);
virtual void onParticipatingGroups(const std::vector<string>& paramVector);
virtual void onLeaveGroup(const std::string& paramString);
// Information providing
- void NotifyEvent(TCHAR* title, TCHAR* info, MCONTACT contact, DWORD flags, TCHAR* url = NULL);
- void NotifyEvent(const string& title, const string& info, MCONTACT contact, DWORD flags, TCHAR* url = NULL);
+ void NotifyEvent(const TCHAR *title, const TCHAR *info, MCONTACT contact, DWORD flags, TCHAR *url = NULL);
+ void NotifyEvent(const string &title, const string &info, MCONTACT contact, DWORD flags, TCHAR *url = NULL);
};
#endif
\ No newline at end of file |