wxFlickrClient.h

00001 // wxFlickrClient.h: Schnittstelle für die Klasse wxFlickrClient.
00002 //
00004 
00005 #if !defined(AFX_WXFLICKRCLIENT_H__58F0F436_7CBC_40E6_ADC4_5C1A28B28A9F__INCLUDED_)
00006 #define AFX_WXFLICKRCLIENT_H__58F0F436_7CBC_40E6_ADC4_5C1A28B28A9F__INCLUDED_
00007 
00008 // wx includes
00009 #include <wx/socket.h>
00010 
00011 // TinyXML includes
00012 #include "includes/tinyxml_2_4_2/tinyxml.h"
00013 
00014 // local includes
00015 #include "wxFlickrEvent.h"
00016 #include "wxFlickrData.h"
00017 
00019 namespace wxFlickrAPI {
00020 
00021   // forward declarations
00022   class wxFlickrAPIMethod;
00023 
00024   enum CommunicationType {
00026     REST,
00029     //XMLRPC,
00030     // SOAP,
00031   };
00032 
00034   class wxFlickrClient : public wxSocketClient {
00035   public:
00036     friend class wxFlickrAPIMethod;
00037     friend class Upload;
00038     wxFlickrClient(wxString sAPIKey, wxString sSharedSecret);
00039     virtual ~wxFlickrClient();
00040     void SetSocketEventHandler(wxEvtHandler& handler, int iId = -1, bool bDeleteOnDestruction = FALSE);
00041     AuthData *GetAuthData();
00042     wxString GetAPIKey();
00043     void SetAuthData(AuthData *pData, bool bCopy = FALSE);
00044     void SetFlickrHandler(wxEvtHandler* pFlHandler);
00045     bool IsReady();
00046     bool IsSignedIn();
00047     void ForwardFlickrResponse(TiXmlNode *pFlickrTree, bool bIsErrorMsg);
00048 
00049   protected:
00050     virtual bool Connect(bool bWait = TRUE);
00051     void SetCurrentMethod(wxFlickrAPIMethod *pMethod);
00052     virtual void Send2Flickr(wxString sMethod, StrStrHashMap args, wxFlickrAPIMethod *pSender = NULL, bool bSigned = FALSE) = 0;
00053     void UploadPhoto(wxString sImage, StrStrHashMap args, wxFlickrAPIMethod *pSender);
00054     wxString BuildSignature(wxArrayString aSortedArgs);
00055     wxEvtHandler *GetFlickrHandler();
00056     void SendWhileNotReadyErr(wxString sFullMethodName);
00057 
00059     wxEvtHandler *m_pFlHandler;
00061     wxFlickrAPIMethod *m_pCurrentMethod;
00063     wxString m_sAPIKey;
00065     wxString m_sSharedSecret;
00067     wxIPV4address m_FlickrURL;
00069     AuthData *m_pAuthData;
00070   private:
00071     wxEvtHandler *m_pSocketEventHandler;
00072   };
00073 
00076   class wxFlickrAPIMethod : public wxObject {
00077   public:
00078     enum State {
00080       Idle,
00081     };
00082     // \todo using standard constructor causes m_pClient == NULL !
00083     wxFlickrAPIMethod();
00084     virtual ~wxFlickrAPIMethod();
00085     virtual void OnFlickrResponse(TiXmlNode *pFlickrTree, bool bIsErrorMsg);
00086     virtual void SetArg(wxString sArgName, wxString sValue);
00087     bool IsReady();
00088     void NotSignedErr(wxString sMethod);
00089     wxString BuildSignature(wxArrayString aSortedArgs);
00090   protected:
00091     void Send2Flickr(wxString sMethod, bool bSigned = FALSE);
00092     wxString m_sMethodPrefix;
00093     void PostFlickrEvent(wxFlickrData *pDataOut, wxFlickrEvent::Type iType);
00094     void PostFlickrError(wxFlickrError *pError);
00095     void SendWhileNotReadyErr(wxString sFullMethodName);
00096     void ReceiveWhileNotWaitingErr();
00097     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00098     void SimpleProcessResponse(TiXmlNode *pResponse);
00099     virtual void ProcessErrorResponse(TiXmlNode *pErrorMsg);
00100     wxFlickrClient *m_pClient;
00101     int m_iState;
00102   private:
00103     DECLARE_ABSTRACT_CLASS(wxFlickrAPIMethod)
00105     StrStrHashMap m_Args;
00106   };
00107 
00109   class wxFlickrClientREST : public wxFlickrClient {
00110   public:
00111     wxFlickrClientREST(wxString sAPIKey, wxString sSharedSecret) : wxFlickrClient(sAPIKey, sSharedSecret) {};
00112     virtual void Send2Flickr(wxString sMethod, StrStrHashMap args, wxFlickrAPIMethod *pSender = NULL, bool bSigned = FALSE);
00113   };
00114 
00116   class wxFlickrClientXMLRPC : public wxFlickrClient {
00117   public:
00118     wxFlickrClientXMLRPC(wxString sAPIKey, wxString sSharedSecret) : wxFlickrClient(sAPIKey, sSharedSecret) {};
00119     virtual void Send2Flickr(wxString sMethod, StrStrHashMap args, wxFlickrAPIMethod *pSender = NULL, bool bSigned = FALSE);
00120   };
00121 
00123   class Upload : public wxFlickrAPIMethod {
00124   public:
00125     enum State {
00126       Idle,
00127       Waiting4Ok,
00128     };
00129     Upload() {};
00130     Upload(wxFlickrClient *pClient);
00131     virtual ~Upload();
00132     void DoUpload();
00133     void SetImageFileName(wxString sImage);
00134   protected:
00135     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00136   private:
00137     wxString m_sImage;
00138     DECLARE_DYNAMIC_CLASS(Auth)
00139   };
00140 
00142   class Auth : public wxFlickrAPIMethod {
00143   public:
00144     enum State {
00145       Idle,
00146       Waiting4Frob,
00147       Waiting4Token,
00148     };
00149     Auth() {};
00150     Auth(wxFlickrClient *pClient, wxString sPerms);
00151     virtual ~Auth();
00152     void CheckToken();
00153     void GetFrob();
00154     void GetToken();
00155   protected:
00156     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00157     void ProcessFrob(TiXmlNode *pResponse);
00158     void ProcessToken(TiXmlNode *pResponse);
00159   private:
00160     DECLARE_DYNAMIC_CLASS(Auth)
00161     wxString m_sPerms;
00162   };
00163 
00165   class Blogs : public wxFlickrAPIMethod {
00166   public:
00167     enum State {
00168       Idle,
00169       Waiting4List,
00170       Waiting4Post,
00171     };
00172     Blogs() {};
00173     Blogs(wxFlickrClient *pClient);
00174     virtual ~Blogs();
00175     void GetList();
00176     void PostPhoto();
00177   protected:
00178     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00179   private:
00180     DECLARE_DYNAMIC_CLASS(Blogs)
00181   };
00182 
00184   class Contacts : public wxFlickrAPIMethod {
00185   public:
00186     enum State {
00187       Idle,
00188       Waiting4List,
00189     };
00190     Contacts() {};
00191     Contacts(wxFlickrClient *pClient);
00192     virtual ~Contacts();
00193     void GetList();
00194     void GetPublicList();
00195   protected:
00196     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00197   private:
00198     DECLARE_DYNAMIC_CLASS(Contacts)
00199   };
00200 
00202   class Favorites : public wxFlickrAPIMethod {
00203   public:
00204     enum State {
00205       Idle,
00206       Waiting4List,
00207       Waiting4Add,
00208       Waiting4Remove,
00209     };
00210     Favorites() {};
00211     Favorites(wxFlickrClient *pClient);
00212     virtual ~Favorites();
00213     void Add();
00214     void GetList();
00215     void GetPublicList();
00216     void Remove();
00217   protected:
00218     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00219     void ProcessList(TiXmlNode *pResponse);
00220   private:
00221     DECLARE_DYNAMIC_CLASS(Favorites)
00222   };
00223 
00225   class Groups : public wxFlickrAPIMethod {
00226   public:
00227     enum State {
00228       Idle,
00229       Waiting4Data,
00230     };
00231     Groups() {};
00232     Groups(wxFlickrClient *pClient);
00233     virtual ~Groups();
00234     void Browse();
00235     void GetInfo();
00236     void Search();
00237   protected:
00238     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00239   private:
00240     DECLARE_DYNAMIC_CLASS(Groups)
00241   };
00242 
00244   class GroupsPools : public wxFlickrAPIMethod {
00245   public:
00246     enum State {
00247       Idle,
00248       Waiting4Photos,
00249       Waiting4Data,
00250     };
00251     GroupsPools(wxFlickrClient *pClient);
00252     GroupsPools() {};
00253     virtual ~GroupsPools();
00254     void Add();
00255     void GetContext();
00256     void GetGroups();
00257     void GetPhotos();
00258     void Remove();
00259   protected:
00260     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00261   private:
00262     DECLARE_DYNAMIC_CLASS(GroupsPools)
00263   };
00264 
00266   class Interestingness : public wxFlickrAPIMethod {
00267   public:
00268     enum State {
00269       Idle,
00270       Waiting4List,
00271     };
00272     Interestingness() {};
00273     Interestingness(wxFlickrClient *pClient);
00274     virtual ~Interestingness();
00275     void GetList();
00276   protected:
00277     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00278   private:
00279     DECLARE_DYNAMIC_CLASS(Interestingness)
00280   };
00281 
00283   class People : public wxFlickrAPIMethod {
00284   public:
00285     enum State {
00286       Idle,
00287       Waiting4Data,
00288       Waiting4Photos,
00289     };
00290     People() {};
00291     People(wxFlickrClient *pClient);
00292     virtual ~People();
00293     void  FindByEmail();
00294     void FindByUsername();
00295     void GetInfo();
00296     void GetPublicGroups();
00297     void GetPublicPhotos();
00298     void GetUploadStatus();
00299   protected:
00300     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00301     void ProcessList(TiXmlNode *pResponse);
00302   private:
00303     DECLARE_DYNAMIC_CLASS(People)
00304   };
00305 
00307   class Photos : public wxFlickrAPIMethod {
00308   public:
00309     enum State {
00310       Idle,
00311       Waiting4Photos,
00312       Waiting4Ok,
00313       Waiting4Data,
00314     };
00315     Photos() {};
00316     Photos(wxFlickrClient *pClient);
00317     virtual ~Photos();
00318     //virtual void OnFlickrResponse(TiXmlNode *pFlickrTree);
00319 
00320     void AddTags();
00321     void Delete();
00322     void GetAllContexts();
00323     void GetContactsPhotos();
00324     void GetContactsPublicPhotos();
00325     void GetContext();
00326     void GetCounts();
00327     void GetExif();
00328     void GetInfo();
00329     void GetNotInSet();
00330     void GetPerms();
00331     void GetRecent();
00332     void GetSizes();
00333     void GetUntagged();
00334     void RemoveTag();
00335     void Search();
00336     void SetDates();
00337     void SetMeta();
00338     void SetPerms();
00339     void SetTags();
00340   protected:
00341     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00342     void ProcessSearch(TiXmlNode *pResponse);
00343     void ProcessContexts(TiXmlNode *pResponse);
00344   private:
00345     DECLARE_DYNAMIC_CLASS(Photos)
00346   };
00347 
00349   class PhotosLicenses : public wxFlickrAPIMethod {
00350   public:
00351     enum State {
00352       Idle,
00353       Waiting4Data,
00354     };
00355     PhotosLicenses() {};
00356     PhotosLicenses(wxFlickrClient *pClient);
00357     virtual ~PhotosLicenses();
00358     void GetInfo();
00359     void SetLicense();
00360   protected:
00361     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00362   private:
00363     DECLARE_DYNAMIC_CLASS(PhotosLicenses)
00364   };
00365 
00367   class PhotosNotes : public wxFlickrAPIMethod {
00368   public:
00369     enum State {
00370       Idle,
00371       Waiting4Data,
00372     };
00373     PhotosNotes() {};
00374     PhotosNotes(wxFlickrClient *pClient);
00375     virtual ~PhotosNotes();
00376     void Add();
00377     void Delete();
00378     void Edit();
00379   protected:
00380     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00381   private:
00382     DECLARE_DYNAMIC_CLASS(PhotosNotes)
00383   };
00384 
00386   class PhotosTransform : public wxFlickrAPIMethod {
00387   public:
00388     enum State {
00389       Idle,
00390       Waiting4Data,
00391     };
00392     PhotosTransform() {};
00393     PhotosTransform(wxFlickrClient *pClient);
00394     virtual ~PhotosTransform();
00395     void Rotate();
00396   protected:
00397     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00398   private:
00399     DECLARE_DYNAMIC_CLASS(PhotosTransform)
00400   };
00401 
00403   class PhotosUpload : public wxFlickrAPIMethod {
00404   public:
00405     enum State {
00406       Idle,
00407       Waiting4Data,
00408     };
00409     PhotosUpload() {};
00410     PhotosUpload(wxFlickrClient *pClient);
00411     virtual ~PhotosUpload();
00412     void CheckTickets();
00413   protected:
00414     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00415   private:
00416     DECLARE_DYNAMIC_CLASS(PhotosUpload)
00417   };
00418 
00420   class Photosets : public wxFlickrAPIMethod {
00421   public:
00422     enum State {
00423       Idle,
00424       Waiting4Data,
00425       Waiting4Photos,
00426     };
00427     Photosets() {};
00428     Photosets(wxFlickrClient *pClient);
00429     virtual ~Photosets();
00430     void AddPhoto();
00431     void Create();
00432     void Delete();
00433     void EditMeta();
00434     void EditPhotos();
00435     void GetContext();
00436     void GetInfo();
00437     void GetList();
00438     void GetPhotos();
00439     void OrderSets();
00440     void RemovePhoto();
00441   protected:
00442     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00443   private:
00444     DECLARE_DYNAMIC_CLASS(Photosets)
00445   };
00446 
00448   class Reflection : public wxFlickrAPIMethod {
00449   public:
00450     enum State {
00451       Idle,
00452       Waiting4Data,
00453     };
00454     Reflection() {};
00455     Reflection(wxFlickrClient *pClient);
00456     virtual ~Reflection();
00457     void GetMethodInfo();
00458     void GetMethods();
00459   protected:
00460     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00461   private:
00462     DECLARE_DYNAMIC_CLASS(Reflection)
00463   };
00464 
00466   class Tags : public wxFlickrAPIMethod {
00467   public:
00468     enum State {
00469       Idle,
00470       Waiting4Data
00471     };
00472     Tags() {};
00473     Tags(wxFlickrClient *pClient);
00474     virtual ~Tags();
00475     void GetListPhoto();
00476     void GetListUser();
00477     void GetListUserPopular();
00478     void GetRelated();
00479   protected:
00480     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00481   private:
00482     DECLARE_DYNAMIC_CLASS(Tags)
00483   };
00484 
00486   class Test : public wxFlickrAPIMethod {
00487   public:
00488     enum State {
00489       Idle,
00490       Waiting4Data,
00491     };
00492     Test() {};
00493     Test(wxFlickrClient *pClient);
00494     virtual ~Test();
00495     void Echo();
00496     void Login();
00497   protected:
00498   private:
00499     DECLARE_DYNAMIC_CLASS(Test)
00500   };
00501 
00503   class URLs : public wxFlickrAPIMethod {
00504   public:
00505     enum State {
00506       Idle,
00507       Waiting4Data,
00508     };
00509     URLs() {};
00510     URLs(wxFlickrClient *pClient);
00511     virtual ~URLs();
00512     void GetGroup();
00513     void GetUserPhotos();
00514     void GetUserProfile();
00515     void LookupGroup();
00516     void LookupUser();
00517   protected:
00518     virtual void ProcessFlickrResponse(TiXmlNode *pResponse);
00519   private:
00520     DECLARE_DYNAMIC_CLASS(URLs)
00521   };
00522 }
00523 
00524 #endif // !defined(AFX_WXFLICKRCLIENT_H__58F0F436_7CBC_40E6_ADC4_5C1A28B28A9F__INCLUDED_)

Generated on Mon Feb 20 11:06:41 2006 for wxFlickr by  doxygen 1.4.6-NO