• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

SugarUnixAccountHandler.h

Go to the documentation of this file.
00001 /* Copyright (C) 2007 One Laptop Per Child
00002  * Author: Marc Maurer <uwog@uwog.net>
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301 USA.
00018  */
00019 
00020 #ifndef __SUGARACCOUNTHANDLER__
00021 #define __SUGARACCOUNTHANDLER__
00022 
00023 #include <set>
00024 
00025 #include <account/xp/AccountHandler.h>
00026 #include <dbus/dbus.h>
00027 #include <dbus/dbus-glib.h>
00028 #include <dbus/dbus-glib-lowlevel.h>
00029 #include "SugarBuddy.h"
00030 
00031 #define SUGAR_STATIC_STORAGE_TYPE "com.abisource.abiword.abicollab.backend.sugar"
00032 
00033 extern AccountHandlerConstructor SugarAccountHandlerConstructor;
00034 
00035 class Session;
00036 class FV_View;
00037 
00038 class SugarAccountHandler : public AccountHandler
00039 {
00040 public:
00041     static SugarAccountHandler*             getHandler();
00042     SugarAccountHandler(); // TODO: this constructor shouldn't be public
00043     virtual ~SugarAccountHandler();
00044 
00045     // housekeeping
00046     static UT_UTF8String                    getStaticStorageType();
00047     virtual UT_UTF8String                   getStorageType()
00048         { return getStaticStorageType(); }
00049     virtual UT_UTF8String                   getDescription();
00050     virtual UT_UTF8String                   getDisplayType();
00051 
00052     // dialog management
00053     virtual void                            embedDialogWidgets(void* /*pEmbeddingParent*/)
00054         { UT_ASSERT_HARMLESS(UT_NOT_REACHED); }
00055     virtual void                            removeDialogWidgets(void* /*pEmbeddingParent*/)
00056         { UT_ASSERT_HARMLESS(UT_NOT_REACHED); }
00057     virtual bool                            canDelete()
00058         { return false; }
00059     virtual bool                            canEditProperties()
00060         { return false; }
00061     virtual void                            loadProperties();
00062     virtual void                            storeProperties();
00063 
00064     // connection management
00065     virtual ConnectResult                   connect();
00066     virtual bool                            disconnect();
00067     virtual bool                            isOnline();
00068 
00069     // user management
00070     virtual BuddyPtr                        constructBuddy(const PropertyMap& props);
00071     virtual BuddyPtr                        constructBuddy(const std::string& descriptor, BuddyPtr pBuddy);
00072     virtual bool                            allowsManualBuddies()
00073         { return false; }
00074     virtual void                            forceDisconnectBuddy(BuddyPtr pBuddy);
00075     virtual bool                            hasAccess(const std::vector<std::string>& vAcl, BuddyPtr pBuddy);
00076     virtual bool                            hasPersistentAccessControl()
00077         { return false; }
00078     virtual bool                            recognizeBuddyIdentifier(const std::string& identifier);
00079 
00080     // session management
00081     virtual bool                            allowsSessionTakeover()
00082         { return true; }
00083     virtual bool                            canManuallyStartSession()
00084         { return false; }
00085 
00086     // packet management
00087     virtual bool                            send(const Packet* pPacket);
00088     virtual bool                            send(const Packet* pPacket, BuddyPtr buddy);
00089     Packet*                                 createPacket(const std::string& packet, BuddyPtr pBuddy);
00090 
00091     // event management
00092     void                                    handleEvent(Session& pSession);
00093 
00094     // signal management
00095     virtual void                            signal(const Event& event, BuddyPtr pSource);
00096 
00097     // tube & buddy management
00098     SugarBuddyPtr                           getBuddy(const UT_UTF8String& dbusAddress);
00099     bool                                    offerTube(FV_View* pView, const UT_UTF8String& tubeDBusAddress);
00100     bool                                    joinTube(FV_View* pView, const UT_UTF8String& tubeDBusAddress);
00101     bool                                    disconnectTube(FV_View* pView);
00102     bool                                    joinBuddy(FV_View* pView, const UT_UTF8String& buddyDBusAddress);
00103     bool                                    disjoinBuddy(FV_View* pView, const UT_UTF8String& buddyDBusAddress);
00104 
00105     bool                                    isIgnoredBuddy(const UT_UTF8String& buddyName)
00106         { return m_ignoredBuddies.find(buddyName) != m_ignoredBuddies.end(); }
00107 
00108 protected:
00109     bool                                    _send(const Packet* pPacket, const char* dbusAddress);
00110     void                                    _registerEditMethods();
00111     virtual void                            _handlePacket(Packet* packet, BuddyPtr buddy);
00112 
00113 private:
00114     static SugarAccountHandler*             m_pHandler;
00115     DBusConnection*                         m_pTube;
00116     bool                                    m_bIsInSession;
00117     std::set<UT_UTF8String>                 m_ignoredBuddies;
00118     std::string                         m_sSessionId;
00119 };
00120 
00121 #endif /* __SUGARACCOUNTHANDLER__ */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1