My Project
|
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 00028 #pragma once 00029 #include "define.h" 00030 #include <string> 00031 #include "NetworkHelper.h" 00032 #include "Scheduler.h" 00033 #include "FacebookThread.h" 00034 00035 namespace SallyAPI 00036 { 00037 namespace Facebook 00038 { 00047 00048 class DLL_API_SALLY CFacebookManager 00049 { 00050 private: 00051 static SallyAPI::Facebook::CFacebookManager* m_pObject; 00052 SallyAPI::Facebook::CFacebookThread m_tFacebookThread; 00053 std::vector<SallyAPI::GUI::CGUIBaseObject*> m_pNotifierWindows; 00054 std::map<std::string, int> m_mUserImageId; 00055 int m_iUserImageCounter; 00056 SallyAPI::System::CCritSection m_UserImagesLock; 00057 00058 00059 std::string GenerateBaseRequest(const std::string& menu); 00060 void GenerateSallyKey(); 00061 00062 CFacebookManager(); 00063 ~CFacebookManager(); 00064 public: 00065 static SallyAPI::Facebook::CFacebookManager* GetInstance(); 00066 static void DeleteInstance(); 00067 00068 bool IsEnabled(); 00069 00070 std::string RequestData(const std::string& action, std::map<std::string, std::string>& requestMap, 00071 std::string& errorMessage, SallyAPI::Network::NETWORK_RETURN& errorCode); 00072 bool SendData(const std::string& action, std::map<std::string, std::string>& requestMap); 00073 bool SendStatusMessage(const std::string& explicidAppName, const std::string& appName, 00074 const std::string& message, const std::string& action, const std::string& actionName); 00075 00076 // attach listeners 00077 void SendUpdateToRegistedNotifier(); 00078 void RegisterStatusUpdateNotifier(SallyAPI::GUI::CGUIBaseObject* window); 00079 00080 bool UpdateFacebookUserInfo(); 00081 00082 std::string GetFacebookUserName(); 00083 std::string GetFacebookUserId(); 00084 std::string GetSallyKey(); 00085 std::string GetFacebookAccessToken(); 00086 00087 void SetFacebookUserName(const std::string& userName); 00088 00089 void Disable(); 00090 void Enable(const std::string& accessToken, const std::string& userName, 00091 const std::string& userId); 00092 00093 bool ActivateFacebook(); 00094 void ConnectFacebook(); 00095 void ShowErrorMessage(SallyAPI::GUI::CGUIBaseObject* mainWindow); 00096 00097 bool PostMessageToWall(const std::string& message, const std::string& description, 00098 const std::string& link, const std::string& image, 00099 std::string& errorMessage); 00100 bool GetWall(std::string& dataResponse, std::string& errorMessage, 00101 SallyAPI::Network::NETWORK_RETURN& errorCode); 00102 bool GetNews(std::string& dataResponse, std::string& errorMessage, 00103 SallyAPI::Network::NETWORK_RETURN& errorCode); 00104 00105 // Image management 00106 int GetFacebookUserImageId(const std::string& userId); 00107 void DownloadFacebookUserImage(const std::string& imageFolder, const std::string& userId); 00108 bool ReloadAllFacebookUserImages(); 00109 bool LoadFacebookUserImage(const std::string& userId); 00110 }; 00111 } 00112 }