llimview.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLIMVIEW_H
00033 #define LL_LLIMVIEW_H
00034 
00035 #include "llfloater.h"
00036 #include "llinstantmessage.h"
00037 #include "lluuid.h"
00038 
00039 class LLFloaterChatterBox;
00040 class LLUUID;
00041 class LLFloaterIMPanel;
00042 class LLFriendObserver;
00043 class LLFloaterIM;
00044 
00045 class LLIMMgr : public LLSingleton<LLIMMgr>
00046 {
00047 public:
00048         enum EInvitationType
00049         {
00050                 INVITATION_TYPE_INSTANT_MESSAGE = 0,
00051                 INVITATION_TYPE_VOICE = 1,
00052                 INVITATION_TYPE_IMMEDIATE = 2
00053         };
00054 
00055         LLIMMgr();
00056         virtual ~LLIMMgr();
00057 
00058         // Add a message to a session. The session can keyed to sesion id
00059         // or agent id.
00060         void addMessage(const LLUUID& session_id,
00061                                         const LLUUID& target_id,
00062                                         const char* from,
00063                                         const char* msg,
00064                                         const char* session_name = NULL,
00065                                         EInstantMessage dialog = IM_NOTHING_SPECIAL,
00066                                         U32 parent_estate_id = 0,
00067                                         const LLUUID& region_id = LLUUID::null,
00068                                         const LLVector3& position = LLVector3::zero,
00069                                         bool link_name = false);
00070 
00071         void addSystemMessage(const LLUUID& session_id, const LLString& message_name, const LLString::format_map_t& args);
00072 
00073         // This method returns TRUE if the local viewer has a session
00074         // currently open keyed to the uuid. The uuid can be keyed by
00075         // either session id or agent id.
00076         BOOL isIMSessionOpen(const LLUUID& uuid);
00077 
00078         // This adds a session to the talk view. The name is the local
00079         // name of the session, dialog specifies the type of
00080         // session. Since sessions can be keyed off of first recipient or
00081         // initiator, the session can be matched against the id
00082         // provided. If the session exists, it is brought forward.  This
00083         // method accepts a group id or an agent id. Specifying id = NULL
00084         // results in an im session to everyone. Returns the uuid of the
00085         // session.
00086         LLUUID addSession(const std::string& name,
00087                                           EInstantMessage dialog,
00088                                           const LLUUID& other_participant_id);
00089 
00090         // Adds a session using a specific group of starting agents
00091         // the dialog type is assumed correct. Returns the uuid of the session.
00092         LLUUID addSession(const std::string& name,
00093                                           EInstantMessage dialog,
00094                                           const LLUUID& other_participant_id,
00095                                           const LLDynamicArray<LLUUID>& ids);
00096 
00097         // Creates a P2P session with the requisite handle for responding to voice calls
00098         LLUUID addP2PSession(const std::string& name,
00099                                           const LLUUID& other_participant_id,
00100                                           const LLString& voice_session_handle);
00101 
00102         // This removes the panel referenced by the uuid, and then
00103         // restores internal consistency. The internal pointer is not
00104         // deleted.
00105         void removeSession(const LLUUID& session_id);
00106 
00107         void inviteToSession(
00108                 const LLUUID& session_id, 
00109                 const LLString& session_name, 
00110                 const LLUUID& caller, 
00111                 const LLString& caller_name,
00112                 EInstantMessage type,
00113                 EInvitationType inv_type, 
00114                 const LLString& session_handle = LLString::null);
00115 
00116         //Updates a given session's session IDs.  Does not open,
00117         //create or do anything new.  If the old session doesn't
00118         //exist, then nothing happens.
00119         void updateFloaterSessionID(const LLUUID& old_session_id,
00120                                                                 const LLUUID& new_session_id);
00121 
00122         void processIMTypingStart(const LLIMInfo* im_info);
00123         void processIMTypingStop(const LLIMInfo* im_info);
00124 
00125         // Rebuild stuff
00126         void refresh();
00127 
00128         void notifyNewIM();
00129         void clearNewIMNotification();
00130 
00131         // IM received that you haven't seen yet
00132         BOOL getIMReceived() const;
00133 
00134         void            setFloaterOpen(BOOL open);              /*Flawfinder: ignore*/
00135         BOOL            getFloaterOpen();
00136 
00137         LLFloaterChatterBox* getFloater();
00138 
00139         // This method is used to go through all active sessions and
00140         // disable all of them. This method is usally called when you are
00141         // forced to log out or similar situations where you do not have a
00142         // good connection.
00143         void disconnectAllSessions();
00144 
00145         static void     toggle(void*);
00146 
00147         // This is a helper function to determine what kind of im session
00148         // should be used for the given agent.
00149         static EInstantMessage defaultIMTypeForAgent(const LLUUID& agent_id);
00150 
00151         BOOL hasSession(const LLUUID& session_id);
00152 
00153         // This method returns the im panel corresponding to the uuid
00154         // provided. The uuid must be a session id. Returns NULL if there
00155         // is no matching panel.
00156         LLFloaterIMPanel* findFloaterBySession(const LLUUID& session_id);
00157 
00158         static LLUUID computeSessionID(EInstantMessage dialog, const LLUUID& other_participant_id);
00159 
00160         void clearPendingInviation(const LLUUID& session_id);
00161 
00162         LLSD getPendingAgentListUpdates(const LLUUID& session_id);
00163         void addPendingAgentListUpdates(
00164                 const LLUUID& sessioN_id,
00165                 const LLSD& updates);
00166         void clearPendingAgentListUpdates(const LLUUID& session_id);
00167 
00168         //HACK: need a better way of enumerating existing session, or listening to session create/destroy events
00169         const std::set<LLHandle<LLFloater> >& getIMFloaterHandles() { return mFloaters; }
00170 
00171 private:
00172         class LLIMSessionInvite;
00173 
00174         // create a panel and update internal representation for
00175         // consistency. Returns the pointer, caller (the class instance
00176         // since it is a private method) is not responsible for deleting
00177         // the pointer.
00178         LLFloaterIMPanel* createFloater(const LLUUID& session_id,
00179                                                                         const LLUUID& target_id,
00180                                                                         const std::string& name,
00181                                                                         EInstantMessage dialog,
00182                                                                         BOOL user_initiated = FALSE);
00183 
00184         LLFloaterIMPanel* createFloater(const LLUUID& session_id,
00185                                                                         const LLUUID& target_id,
00186                                                                         const std::string& name,
00187                                                                         const LLDynamicArray<LLUUID>& ids,
00188                                                                         EInstantMessage dialog,
00189                                                                         BOOL user_initiated = FALSE);
00190 
00191         // This simple method just iterates through all of the ids, and
00192         // prints a simple message if they are not online. Used to help
00193         // reduce 'hello' messages to the linden employees unlucky enough
00194         // to have their calling card in the default inventory.
00195         void noteOfflineUsers(LLFloaterIMPanel* panel, const LLDynamicArray<LLUUID>& ids);
00196         void noteMutedUsers(LLFloaterIMPanel* panel, const LLDynamicArray<LLUUID>& ids);
00197 
00198         void processIMTypingCore(const LLIMInfo* im_info, BOOL typing);
00199 
00200         static void inviteUserResponse(S32 option, void* user_data);
00201         static void onInviteNameLookup(const LLUUID& id, const char* first, const char* last, BOOL is_group, void* userdata);
00202 
00203 private:
00204         std::set<LLHandle<LLFloater> > mFloaters;
00205         LLFriendObserver* mFriendObserver;
00206 
00207         // An IM has been received that you haven't seen yet.
00208         BOOL mIMReceived;
00209 
00210         LLSD mPendingInvitations;
00211         LLSD mPendingAgentListUpdates;
00212 };
00213 
00214 
00215 class LLFloaterIM : public LLMultiFloater
00216 {
00217 public:
00218         LLFloaterIM();
00219         /*virtual*/ BOOL postBuild();
00220 
00221         static std::map<std::string,LLString> sEventStringsMap;
00222         static std::map<std::string,LLString> sErrorStringsMap;
00223         static std::map<std::string,LLString> sForceCloseSessionMap;
00224 };
00225 
00226 // Globals
00227 extern LLIMMgr *gIMMgr;
00228 
00229 #endif  // LL_LLIMView_H

Generated on Fri May 16 08:33:41 2008 for SecondLife by  doxygen 1.5.5