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