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         LLIMMgr();
00049         virtual ~LLIMMgr();
00050 
00051         
00052         
00053         void addMessage(const LLUUID& session_id,
00054                                         const LLUUID& target_id,
00055                                         const char* from,
00056                                         const char* msg,
00057                                         const char* session_name = NULL,
00058                                         EInstantMessage dialog = IM_NOTHING_SPECIAL,
00059                                         U32 parent_estate_id = 0,
00060                                         const LLUUID& region_id = LLUUID::null,
00061                                         const LLVector3& position = LLVector3::zero);
00062 
00063         void addSystemMessage(const LLUUID& session_id, const LLString& message_name, const LLString::format_map_t& args);
00064 
00065         
00066         
00067         
00068         BOOL isIMSessionOpen(const LLUUID& uuid);
00069 
00070         
00071         
00072         
00073         
00074         
00075         
00076         
00077         
00078         LLUUID addSession(const std::string& name,
00079                                           EInstantMessage dialog,
00080                                           const LLUUID& other_participant_id);
00081 
00082         
00083         
00084         LLUUID addSession(const std::string& name,
00085                                           EInstantMessage dialog,
00086                                           const LLUUID& other_participant_id,
00087                                           const LLDynamicArray<LLUUID>& ids);
00088 
00089         
00090         LLUUID addP2PSession(const std::string& name,
00091                                           const LLUUID& other_participant_id,
00092                                           const LLString& voice_session_handle);
00093 
00094         
00095         
00096         
00097         void removeSession(const LLUUID& session_id);
00098 
00099         void inviteToSession(const LLUUID& session_id, 
00100                                                 const LLString& session_name, 
00101                                                 const LLUUID& caller, 
00102                                                 const LLString& caller_name,
00103                                                 EInstantMessage type,
00104                                                 const LLString& session_handle = LLString::null);
00105 
00106         
00107         
00108         
00109         void updateFloaterSessionID(const LLUUID& old_session_id,
00110                                                                 const LLUUID& new_session_id);
00111 
00112         void processIMTypingStart(const LLIMInfo* im_info);
00113         void processIMTypingStop(const LLIMInfo* im_info);
00114 
00115         
00116         void refresh();
00117 
00118         void notifyNewIM();
00119         void clearNewIMNotification();
00120 
00121         
00122         BOOL getIMReceived() const;
00123 
00124         void            setFloaterOpen(BOOL open);              
00125         BOOL            getFloaterOpen();
00126 
00127         LLFloaterChatterBox* getFloater();
00128 
00129         
00130         
00131         
00132         
00133         void disconnectAllSessions();
00134 
00135         static void     toggle(void*);
00136 
00137         
00138         
00139         static EInstantMessage defaultIMTypeForAgent(const LLUUID& agent_id);
00140 
00141         BOOL hasSession(const LLUUID& session_id);
00142 
00143         
00144         
00145         
00146         LLFloaterIMPanel* findFloaterBySession(const LLUUID& session_id);
00147 
00148         static LLUUID computeSessionID(EInstantMessage dialog, const LLUUID& other_participant_id);
00149 
00150         void clearPendingVoiceInviation(const LLUUID& session_id);
00151 
00152         LLSD getPendingAgentListUpdates(const LLUUID& session_id);
00153         void addPendingAgentListUpdates(
00154                 const LLUUID& sessioN_id,
00155                 const LLSD& updates);
00156         void clearPendingAgentListUpdates(const LLUUID& session_id);
00157 
00158 private:
00159         class LLIMSessionInvite;
00160 
00161         
00162         
00163         
00164         
00165         LLFloaterIMPanel* createFloater(const LLUUID& session_id,
00166                                                                         const LLUUID& target_id,
00167                                                                         const std::string& name,
00168                                                                         EInstantMessage dialog,
00169                                                                         BOOL user_initiated = FALSE);
00170 
00171         LLFloaterIMPanel* createFloater(const LLUUID& session_id,
00172                                                                         const LLUUID& target_id,
00173                                                                         const std::string& name,
00174                                                                         const LLDynamicArray<LLUUID>& ids,
00175                                                                         EInstantMessage dialog,
00176                                                                         BOOL user_initiated = FALSE);
00177 
00178         
00179         
00180         
00181         
00182         void noteOfflineUsers(LLFloaterIMPanel* panel, const LLDynamicArray<LLUUID>& ids);
00183 
00184         void processIMTypingCore(const LLIMInfo* im_info, BOOL typing);
00185 
00186         static void inviteUserResponse(S32 option, void* user_data);
00187         static void onInviteNameLookup(const LLUUID& id, const char* first, const char* last, BOOL is_group, void* userdata);
00188 
00189 private:
00190         std::set<LLViewHandle> mFloaters;
00191         LLFriendObserver* mFriendObserver;
00192 
00193         
00194         BOOL mIMReceived;
00195 
00196         LLSD mPendingVoiceInvitations;
00197         LLSD mPendingAgentListUpdates;
00198 };
00199 
00200 
00201 class LLFloaterIM : public LLMultiFloater
00202 {
00203 public:
00204         LLFloaterIM();
00205          BOOL postBuild();
00206 };
00207 
00208 
00209 extern LLIMMgr *gIMMgr;
00210 
00211 #endif  // LL_LLIMView_H