#pragma once //========================================================================== // * Æ®À§ÅÍ ½Ã½ºÅÛ Âü°í( API ¿äû Á¦ÇÑ ) * // // Æ®À§ÅÍ´Â Client ¾îÇÿ¡¼­ ´Ù¾çÇÑ ¿äûÀ» Çϴµ¥, // ±âº»ÀûÀ¸·Î Æ®À§Åͼ­ ½Ã°£´ç 150ȸ·Î Á¦ÇÑÇϰí ÀÖ´Ù. // ±× ÀÌ»óÀÇ ¿äûÀ» ÇÏ¿´À» ¶§´Â Æ®À§ÅÍ¿¡¼­ Limit »óÅ·ΠÀüȯ½ÃÄÑ // ¾à 1½Ã°£ µ¿¾È ¾îÇÿ¡¼­ÀÇ ¿äûÀ» Á¦ÇÑÇÑ´Ù. // //========================================================================== #include "UIWindow.h" #include "StyleListBox.h" #include "twitcurl.h" #include "Queue.h" const unsigned long SHOW_FAIL_MSG_TIME = 3000; // 3ÃÊ( Áߺ¹ ¸Þ½ÃÁö ¼Û½ÅÀ¸·Î ÀÎÇÑ ½ÇÆÐ¸¦ 3Ãʰ£ º¸¿©ÁØ´Ù. ) const unsigned long HTTP_REQUEST_TIME = 60000; // 1ºÐ ( NºÐ ¸¶´Ù Æ®À§ÅÍ Data Àç ¼Û½Å ¿äû ) const unsigned long TWIT_REQUEST_LIMIT_TIME = 3600000; // 1½Ã°£ ( 1½Ã°£ µ¿¾È 150°Ç ÀÌ»óÀÇ Æ®À§ÅÍ¿¡ ¿äû½Ã Á¦ÇÑÀÌ °É¸² ) const unsigned char TWIT_REQUEST_LIMIT_COUNT = 127; // 1½Ã°£ µ¿¾È Api ¿¡¼­ Request ¿äû Á¦ÇÑ °¹¼ö const unsigned char MAX_TWITTER_RENDER_LIST = 6; // Æ®À§ÅÍ ¸®½ºÆ® ¹Ú½º¿¡¼­ º¸¿©ÁÖ´Â °¹¼ö const unsigned char MAX_TWITTER_HAVE_LIST = 20; // Æ®À§ÅÍ ¸®½ºÆ® ¹Ú½º ÃÖ´ë º¸À¯ °¹¼ö const unsigned int PRINT_TEXT_WIDTH = 285; // Æ®À§ÅÍ ¸®½ºÆ® ¹Ú½º ÅØ½ºÅ© ³»¿ë °¡·Î Å©±â const unsigned char PROFILE_ICON_SIZE = 28; // Æ®À§ÅÍ ÇÁ·ÎÇÊ À̹ÌÁö Å©±â const unsigned char DUPLICATION_COUNT_CHECK = 10; // Æ®À§ÅÍ ÇÁ·ÎÇÊ À̹ÌÁö Å©±â const unsigned char TWIT_EVENT_ENHANCE_STEP = 7; // Æ®À§ÅÍ À̺¥Æ® ¸Þ½ÃÁö °­È­ ´Ü°è const unsigned char TWIT_EVENT_LEVELUP = 10; // Æ®À§ÅÍ À̺¥Æ® ¸Þ½ÃÁö ·¹º§ ´ÜÀ§ class cEditBox; class cMultiEditBox; class cButton; class cLabel; class cTwitterListBox; class cCheckBox; /// Thread¿¡¼­ HTTP·Î ºÎÅÍ ¼ö½ÅÇÑ ¹öÆÛ ÀúÀå struct sImgBufInfo { char* mBuf; DWORD mBufLen; sImgBufInfo() { ::ZeroMemory( this, sizeof(sImgBufInfo) ); } }; /// Thread¿¡¼­ EncodingÇÑ ÅØ½ºÆ® Á¤º¸ ÀúÀå struct sTwitDataInfo { unsigned long mUserIdx; __int64 mTextIdx; cStringT mText; cStringT mDate; cStringT mID; sTwitDataInfo() { ::ZeroMemory( this,sizeof(sTwitDataInfo)); } }; struct sThreadInfo { unsigned char mCommandType; void* mExtraData; sThreadInfo() { ::ZeroMemory( this,sizeof(sThreadInfo)); } }; // Twitter ¸®½ºÆ® ¹Ú½º Extradata Struct struct sTwitterExdata { unsigned long nUserIdx; __int64 nTextIdx; sTwitterExdata() { ::ZeroMemory( this,sizeof(sTwitterExdata)); } }; typedef tHashMap< unsigned long, void* > cImgBufferMap; // Thread¿¡¼­ Http·Î ºÎÅÍ Àü¼Û¹ÞÀº ¹öÆÛ ÁÖ¼Ò¸¦ ÀúÀå typedef tArray< void* > cTwitDataMap; // Thread¿¡¼­ Æ®À§ÅÍ ¸Þ½ÃÁö Á¤º¸ ÀúÀå typedef tHashMap< unsigned long, NiTexturePtr > cTwitterTextureMap; // ÅØ½ºÃÄ Á¤º¸ ÀúÀå typedef tList< __int64 > cTwitterTextIdxList; // ÅØ½ºÃÄ Á¤º¸ ÀúÀå struct sThreadShareData { cImgBufferMap mImgBufferMap; // À̹ÌÁö Àӽà ¹öÆÛ cTwitDataMap mTwitDataMap; // Æ®À§ÅÍ Data cTwitterTextureMap mTwitterTextureMap; // ÅØ½ºÃÄ ¸®½ºÆ® cTwitterTextIdxList mTiwtTextIdxList; // ÀÛ¼ºÇÑ ÃÖ±Ù 10°³ °Ô½Ã¹°ÀÇ ±Û idx ÀúÀå twitCurl mpTwitterContoller; // Æ®À§ÅÍ ÄÁÆ®·Ñ·¯ CRITICAL_SECTION mCs; unsigned char mStateThread; // Thread ÁøÇà »óÅ unsigned char mResultThread; // Thread °á°ú bool mShutDown; // Thread ShuDown int mResetRemainMinute; // ½Ã°£´ç 150 Req ResetTime }; // Æ®À§ÅÍ À̺¥Æ® Á¾·ù enum eTwitEventType { eTWITEVENT_QUEST, eTWITEVENT_MONSTER, eTWITEVENT_LEVEL, eTWITEVENT_ENHANCE, eTWITEVENT_MAX, }; /// Æ®À§ÅÍ À̺¥Æ® struct sTwitterEvent { eTwitEventType mEvent; void* mExData; sTwitterEvent() { ::ZeroMemory( this, sizeof(sTwitterEvent) ); } }; struct sTwitterLogInfo { unsigned char mCommandType; unsigned long mReqTime; }; /// LBS : thread¿Í °øÅëÀ¸·Î »ç¿ëÇÏ´Â enumÇüÀ» twitterwindow¿¡¼­ »®´Ï´Ù. /// enumeration enum { // Thread µ¿ÀÛ »óÅ eState_None, // eNone À̿ܿ¡´Â ¸ðµÎ ¾²·¹µå µ¿ÀÛÁß eState_Getting_TimeLineHomeMsg, // ¸®½ºÆ® °»½Å ó¸® »óÅ eState_Sending_UpdateMsg, // ¸Þ¼¼Áö ÀÛ¼º ¿äû »óÅ eState_Sending_EventMsg, // ¸Þ¼¼Áö ÀÛ¼º ¿äû »óÅ eState_Sending_LoginMsg, // ·Î±×ÀΠó¸® ÁøÇà »óÅ eState_Sending_RetweetMsg, // ¸®Æ®À­ ó¸® ÁøÇà »óÅ eState_Sending_FollowMsg, // Follow ó¸® ÁøÇà »óÅ }; /// ¾²·¹µå °á°ú ŸÀÔ¿¡ µû¶ó ¾Ë¸²Ã¢À» ±¸ºÐÇÏ¿© ¿¬´Ù. enum { eResult_None, // eResult_Success_SendMsg, // ¸Þ½ÃÁö Àü¼Û °á°ú eResult_Success_EventMsg, // À̺¥Æ® ¸Þ½ÃÁö Àü¼Û °á°ú eResult_Success_GetList, // ¸®½ºÆ® °»½Å °á°ú eResult_Success_Login, // ·Î±×ÀÎ ¼º°ø½Ã eResult_Success_Retweet, // ¸®Æ®À­ ¼º°ø½Ã eResult_Success_Follow, // Follow ¼º°ø½Ã eResult_Error_Default, // ¿¡·¯ ¹ß»ý »óÅ eResult_Error_NoAccount, // ·Î±×ÀÎ ½Ãµµ½Ã °èÁ¤ Á¤º¸°¡ ¾ø´Â °æ¿ì, ·Î±×ÀÎ ½ÇÆÐ½Ã eResult_Error_UpdateStatus, // ±Û ³²±â±â ½ÇÆÐ eResult_Error_EventUpdateStatus,// À̺¥Æ® ±Û ³²±â±â ½ÇÆÐ eResult_Error_GetTimeLineHome, // ¸®½ºÆ® °¡Á®¿À±â ½ÇÆÐ eResult_Error_NoLogin, // ·Î±×ÀÎ X eResult_Error_Retweet, // ¸®Æ®À­ ½ÇÆÐ eResult_Error_Follow, // Follow ½ÇÆÐ eResult_Error_LimitExceed, // 1½Ã°£´ç 150¹ø ÀÌ»óÀÇ Request ¿äû½Ã ¸®¹Ô »óŶó ½ÇÆÐ! eResult_Error_StatusUpdateLimit,// ÀÏÀÏ 1000°ÇÀÇ ±ÛÀ» ¿Ã¸®°Å³ª ¶Ç´Â ªÀº ½Ã°£ÀÇ ¸¹Àº ±ÛÀ» ¿Ã·Á¼­ Æ®À§ÅÍ¿¡ ÀÇÇØ Á¦ÇÑ»óÅÂÀ϶§ }; class cTwitterWindow : public cUIWindow { public: enum { // Thread µ¿ÀÛ Å¸ÀÔ eCommand_SendUpdate, // ±Û¾²±â eCommand_EventUpdate, // À̺¥Æ® ¸Þ½ÃÁö Àü¼Û eCommand_GetTimeLineHome, // ¸®½ºÆ® °»½Å eCommand_Login, // ·Î±×ÀÎ eCommand_AutoLogin, // ÀÚµ¿ ·Î±×ÀÎ eCommand_Retweet, // RT ¸®Æ®À­ eCommand_Follow // Follow }; enum { // DB °»½Å ŸÀÔ eRegister_OnlySave, // °èÁ¤¸¸ ÀúÀå eRegister_OnlyLogin, // ·Î±×ÀÎ eRegister_LoginAndSave, // ·Î±×ÀÎ + °èÁ¤ ÀúÀå eRegister_Refresh // °èÁ¤ ÃʱâÈ­ }; // Method cTwitterWindow(); virtual ~cTwitterWindow(); virtual void Clear(); virtual void Open(); protected: // Method virtual void OnProcess( unsigned long deltaTime, unsigned long accumTime ); virtual bool OnCreate( cUINodeProperty* pproperty ); virtual void OnCommand( cUINode* caller, unsigned int id ); virtual void OnShow(); virtual void OnHide(); virtual void OnNetLock( int lockTry ); virtual void OnNetUnLock( int lockTry ); public: bool IsLogin(){ return mIsLogin;} void SetLogin( bool bLogin ){ mIsLogin = bLogin;} void LogOut(); void SetDBAccountSave( bool bSave ); bool IsDBSaveAccount(){ return mDBAccountSave; } void SetRegistType( unsigned char nType ){ mIsAccountRegister = nType; } unsigned char GetRegistType(){ return mIsAccountRegister; } LPCSTR GetID(); LPCSTR GetPW(); void CreateTwitterThread( unsigned char nCommandType, void* pExData = NULL ); void DestroyTwitterThread(); static DWORD WINAPI PerformTwitterThread( void* arg ); void AddEvent( sTwitterEvent& twitEvent ); unsigned char ProcessEvent(); bool IsTwitterTextData( __int64 nFindTextIdx ); private: ///============[ UI ]============ cMultiEditBox* mpSendMessage; // ¸Þ½ÃÁö cTwitterListBox* mpTwitListBox; // ¸®½ºÆ® ¹Ú½º cButton* mpSendBtn; // ¸Þ½ÃÁö Àü¼Û cButton* mpRegisterBtn; // °èÁ¤ µî·Ï/ º¯°æ cButton* mpCloseBtn; // ´Ý±â cLabel* mpStateLabel; // Æ®À§ÅÍ ÀÛµ¿ »óÅ ( ·Î±×ÀÎ, ±Û¾²±â, ¸®½ºÆ® °»½Å µîµî ) // unsigned long mUpdateTime; // ´ÙÀ½ °»½Å ½Ã°£ unsigned long mFailShowTime; // ¿¡·¯ ¸Þ½ÃÁö Ãâ·Â ½Ã°£ bool mIsLogin; // ·Î±×ÀÎ ¼º°ø ¿©ºÎ bool mAccountSaveType; // DB¿¡ ÀúÀå ÇÒÁö ¿©ºÎ bool mDBAccountSave; // DB¿¡ ÀúÀå »óÅ unsigned char mIsAccountRegister; // »õ·ÎÀÌ °èÁ¤ µî·ÏÀÎÁö, ÃʱâÈ­ÀÎÁö ±¸ºÐ cString mOldID; cString mOldPW; cStringT mEventMsg[ eTWITEVENT_MAX ]; // Thread HANDLE mTwitterThread; // Æ®À§ÅÍ ¿äû ó¸® ¾²·¹µå bool mEventUpdate; // À̺¥Æ® °»½Å ¿©ºÎ bool mIsSendMsgFail; // Áߺ¹ ¸Þ½ÃÁö Àü¼ÛÀ¸·Î ÀÎÇÑ ½ÇÆÐ ¿©ºÎ bool mUpdateReady; // °»½Å Áغñ »óÅ // DLL Load typedef tArray< HINSTANCE > cDLLArray; cDLLArray mDllArray; // ij¸¯ÅÍ À̺¥Æ®¸¦ ÀûÀç ó¸®(·¹º§¾÷, ¾ÆÀÌÅÛ °­È­, Äù½ºÆ®, ƯÁ¤ ¸ó½ºÅÍ) typedef tQueue cEventQueue; cEventQueue mTwitterEventQueue; }; class cTwitterRegisterWindow : public cUIWindow { public: // Method cTwitterRegisterWindow(); virtual ~cTwitterRegisterWindow(); virtual void Open(); virtual void Clear(); protected: virtual bool OnCreate( cUINodeProperty* pproperty ); virtual void OnCommand( cUINode* caller, unsigned int id ); virtual void OnHide(); virtual void OnNetLock( int lockTry ); virtual void OnNetUnLock( int lockTry ); public: LPCTSTR GetID(); LPCTSTR GetPW(); void SetResetBtnEnable( bool bEnable ); bool IsDBSaveCheckPress(); void SetPressDBSaveCheck( bool bPress ); private: cEditBox* mpID; // ID cEditBox* mpPw; // Password cButton* mpConnectAndSave; // Á¢¼Ó / ÀúÀå cButton* mpCancelBtn; // Ãë¼Ò cButton* mpResetBtn; // ÃʱâÈ­ cCheckBox* mpDBSaveCheck; // DB ÀúÀå }; class cTwitterListBox : public cImageListBox { public: cTwitterListBox( eUINodeType type = eUINODE_LISTBOX ); virtual ~cTwitterListBox(); // ¸®½ºÆ®¿¡ 0¹øÂ° Àε«½º¿¡ ÀÚ·á »ðÀÔ int AddRowAtFirst( LPCTSTR str, unsigned long color, cUIImage* image, void* pExtraData = 0 ); void SetMaxRowCount( unsigned short nCnt ); protected: virtual void OnMouseMove( const cUIPos& pos ); virtual void OnMouseLeft( const cUIPos& pos ); virtual void OnMouseWheel( const cUIPos& pos, int wheel ); virtual void RenderData( cUIFontItemKeeper* pKeeper ); virtual void ShowTwitterTextTip( const cUIPos& pos ); };