00001
00032 #ifndef LL_IMPANEL_H
00033 #define LL_IMPANEL_H
00034
00035 #include "llfloater.h"
00036 #include "lluuid.h"
00037 #include "lldarray.h"
00038 #include "llinstantmessage.h"
00039 #include "llvoiceclient.h"
00040
00041 class LLLineEditor;
00042 class LLViewerTextEditor;
00043 class LLInventoryItem;
00044 class LLInventoryCategory;
00045 class LLIMSpeakerMgr;
00046 class LLPanelActiveSpeakers;
00047
00048 class LLVoiceChannel : public LLVoiceClientStatusObserver
00049 {
00050 public:
00051 typedef enum e_voice_channel_state
00052 {
00053 STATE_NO_CHANNEL_INFO,
00054 STATE_ERROR,
00055 STATE_HUNG_UP,
00056 STATE_READY,
00057 STATE_CALL_STARTED,
00058 STATE_RINGING,
00059 STATE_CONNECTED
00060 } EState;
00061
00062 LLVoiceChannel(const LLUUID& session_id, const LLString& session_name);
00063 virtual ~LLVoiceChannel();
00064
00065 void onChange(EStatusType status, const std::string &channelURI, bool proximal);
00066
00067 virtual void handleStatusChange(EStatusType status);
00068 virtual void handleError(EStatusType status);
00069 virtual void deactivate();
00070 virtual void activate();
00071 virtual void setChannelInfo(
00072 const LLString& uri,
00073 const LLString& credentials);
00074 virtual void getChannelInfo();
00075 virtual BOOL isActive();
00076 virtual BOOL callStarted();
00077 EState getState() { return mState; }
00078
00079 void updateSessionID(const LLUUID& new_session_id);
00080
00081 static LLVoiceChannel* getChannelByID(const LLUUID& session_id);
00082 static LLVoiceChannel* getChannelByURI(LLString uri);
00083 static LLVoiceChannel* getCurrentVoiceChannel() { return sCurrentVoiceChannel; }
00084 static void initClass();
00085
00086 protected:
00087 virtual void setState(EState state);
00088 void setURI(LLString uri);
00089
00090 LLString mURI;
00091 LLString mCredentials;
00092 LLUUID mSessionID;
00093 EState mState;
00094 LLString mSessionName;
00095 LLString::format_map_t mNotifyArgs;
00096 BOOL mIgnoreNextSessionLeave;
00097 LLViewHandle mLoginNotificationHandle;
00098
00099 typedef std::map<LLUUID, LLVoiceChannel*> voice_channel_map_t;
00100 static voice_channel_map_t sVoiceChannelMap;
00101
00102 typedef std::map<LLString, LLVoiceChannel*> voice_channel_map_uri_t;
00103 static voice_channel_map_uri_t sVoiceChannelURIMap;
00104
00105 static LLVoiceChannel* sCurrentVoiceChannel;
00106 };
00107
00108 class LLVoiceChannelGroup : public LLVoiceChannel
00109 {
00110 public:
00111 LLVoiceChannelGroup(const LLUUID& session_id, const LLString& session_name);
00112 virtual ~LLVoiceChannelGroup();
00113
00114 void handleStatusChange(EStatusType status);
00115 void handleError(EStatusType status);
00116 void activate();
00117 void deactivate();
00118 void setChannelInfo(
00119 const LLString& uri,
00120 const LLString& credentials);
00121 void getChannelInfo();
00122
00123 protected:
00124 virtual void setState(EState state);
00125
00126 private:
00127 U32 mRetries;
00128 BOOL mIsRetrying;
00129 };
00130
00131 class LLVoiceChannelProximal : public LLVoiceChannel, public LLSingleton<LLVoiceChannelProximal>
00132 {
00133 public:
00134 LLVoiceChannelProximal();
00135 virtual ~LLVoiceChannelProximal();
00136
00137 void onChange(EStatusType status, const std::string &channelURI, bool proximal);
00138 void handleStatusChange(EStatusType status);
00139 void handleError(EStatusType status);
00140 BOOL isActive();
00141 void activate();
00142 void deactivate();
00143
00144 };
00145
00146 class LLVoiceChannelP2P : public LLVoiceChannelGroup
00147 {
00148 public:
00149 LLVoiceChannelP2P(const LLUUID& session_id, const LLString& session_name, const LLUUID& other_user_id);
00150 virtual ~LLVoiceChannelP2P();
00151
00152 void handleStatusChange(EStatusType status);
00153 void handleError(EStatusType status);
00154 void activate();
00155 void getChannelInfo();
00156
00157 void setSessionHandle(const LLString& handle);
00158
00159 private:
00160 LLString mSessionHandle;
00161 LLUUID mOtherUserID;
00162 };
00163
00164 class LLFloaterIMPanel : public LLFloater
00165 {
00166 public:
00167
00168
00169
00170
00171
00172
00173 LLFloaterIMPanel(const std::string& name,
00174 const LLRect& rect,
00175 const std::string& session_label,
00176 const LLUUID& session_id,
00177 const LLUUID& target_id,
00178 EInstantMessage dialog);
00179 LLFloaterIMPanel(const std::string& name,
00180 const LLRect& rect,
00181 const std::string& session_label,
00182 const LLUUID& session_id,
00183 const LLUUID& target_id,
00184 const LLDynamicArray<LLUUID>& ids,
00185 EInstantMessage dialog);
00186 virtual ~LLFloaterIMPanel();
00187
00188 BOOL postBuild();
00189
00190
00191 void draw();
00192
00193 void onClose(bool app_quitting = FALSE);
00194
00195
00196
00197 BOOL inviteToSession(const LLDynamicArray<LLUUID>& agent_ids);
00198
00199 void addHistoryLine(const LLUUID& source,
00200 const std::string &utf8msg,
00201 const LLColor4& color = LLColor4::white,
00202 bool log_to_file = true);
00203 void addHistoryLine(const std::string &utf8msg,
00204 const LLColor4& color = LLColor4::white,
00205 bool log_to_file = true);
00206 void setInputFocus( BOOL b );
00207
00208 void selectAll();
00209 void selectNone();
00210 void setVisible(BOOL b);
00211
00212 BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
00213 BOOL handleDragAndDrop(S32 x, S32 y, MASK mask,
00214 BOOL drop, EDragAndDropType cargo_type,
00215 void *cargo_data, EAcceptance *accept,
00216 LLString& tooltip_msg);
00217
00218 static void onInputEditorFocusReceived( LLUICtrl* caller, void* userdata );
00219 static void onInputEditorFocusLost(LLUICtrl* caller, void* userdata);
00220 static void onInputEditorKeystroke(LLLineEditor* caller, void* userdata);
00221 static void onCommitChat(LLUICtrl* caller, void* userdata);
00222 static void onTabClick( void* userdata );
00223
00224 static void onClickProfile( void* userdata );
00225 static void onClickGroupInfo( void* userdata );
00226 static void onClickClose( void* userdata );
00227 static void onClickStartCall( void* userdata );
00228 static void onClickEndCall( void* userdata );
00229 static void onClickSend( void* userdata );
00230 static void onClickToggleActiveSpeakers( void* userdata );
00231 static void* createSpeakersPanel(void* data);
00232
00233
00234 static void onClickMuteVoice(LLUICtrl* source, void* user_data);
00235 static void onVolumeChange(LLUICtrl* source, void* user_data);
00236
00237 const LLUUID& getSessionID() const { return mSessionUUID; }
00238 const LLUUID& getOtherParticipantID() const { return mOtherParticipantUUID; }
00239 void updateSpeakersList(LLSD speaker_updates);
00240 void setSpeakersListFromMap(LLSD speaker_list);
00241 void setSpeakersList(LLSD speaker_list);
00242 LLVoiceChannel* getVoiceChannel() { return mVoiceChannel; }
00243 EInstantMessage getDialogType() const { return mDialog; }
00244
00245 void requestAutoConnect();
00246
00247 void sessionInitReplyReceived(const LLUUID& im_session_id);
00248
00249
00250 void processIMTyping(const LLIMInfo* im_info, BOOL typing);
00251 static void chatFromLogFile(LLString line, void* userdata);
00252
00253 private:
00254
00255 void init(const LLString& session_label);
00256
00257
00258 void sendMsg();
00259
00260
00261 BOOL dropCallingCard(LLInventoryItem* item, BOOL drop);
00262 BOOL dropCategory(LLInventoryCategory* category, BOOL drop);
00263
00264
00265 BOOL isInviteAllowed() const;
00266
00267
00268
00269 void setTyping(BOOL typing);
00270
00271
00272 void addTypingIndicator(const std::string &name);
00273
00274
00275 void removeTypingIndicator(const LLIMInfo* im_info);
00276
00277 void sendTypingState(BOOL typing);
00278
00279 static LLFloaterIMPanel* sInstance;
00280
00281 private:
00282 LLLineEditor* mInputEditor;
00283 LLViewerTextEditor* mHistoryEditor;
00284
00285
00286
00287
00288
00289
00290 LLUUID mSessionUUID;
00291
00292 LLVoiceChannel* mVoiceChannel;
00293
00294 BOOL mSessionInitialized;
00295 LLSD mQueuedMsgsForInit;
00296
00297
00298
00299
00300
00301
00302 LLUUID mOtherParticipantUUID;
00303 LLDynamicArray<LLUUID> mSessionInitialTargetIDs;
00304
00305 EInstantMessage mDialog;
00306
00307
00308 BOOL mTyping;
00309
00310
00311 BOOL mOtherTyping;
00312
00313
00314 std::string mOtherTypingName;
00315
00316
00317 S32 mTypingLineStartIndex;
00318
00319 S32 mSessionStartMsgPos;
00320
00321 BOOL mSentTypingState;
00322
00323 BOOL mShowSpeakersOnConnect;
00324
00325 BOOL mAutoConnect;
00326
00327 LLIMSpeakerMgr* mSpeakers;
00328 LLPanelActiveSpeakers* mSpeakerPanel;
00329
00330
00331
00332
00333 LLFrameTimer mFirstKeystrokeTimer;
00334
00335
00336 LLFrameTimer mLastKeystrokeTimer;
00337
00338 void disableWhileSessionStarting();
00339 };
00340
00341
00342 #endif // LL_IMPANEL_H