llimpanel.h

Go to the documentation of this file.
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         /*virtual*/ 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         /*virtual*/ void handleStatusChange(EStatusType status);
00115         /*virtual*/ void handleError(EStatusType status);
00116         /*virtual*/ void activate();
00117         /*virtual*/ void deactivate();
00118         /*vritual*/ void setChannelInfo(
00119                 const LLString& uri,
00120                 const LLString& credentials);
00121         /*virtual*/ 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         /*virtual*/ void onChange(EStatusType status, const std::string &channelURI, bool proximal);
00138         /*virtual*/ void handleStatusChange(EStatusType status);
00139         /*virtual*/ void handleError(EStatusType status);
00140         /*virtual*/ BOOL isActive();
00141         /*virtual*/ void activate();
00142         /*virtual*/ 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         /*virtual*/ void handleStatusChange(EStatusType status);
00153         /*virtual*/ void handleError(EStatusType status);
00154     /*virtual*/ void activate();
00155         /*virtual*/ 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         // The session id is the id of the session this is for. The target
00169         // refers to the user (or group) that where this session serves as
00170         // the default. For example, if you open a session though a
00171         // calling card, a new session id will be generated, but the
00172         // target_id will be the agent referenced by the calling card.
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         /*virtual*/ BOOL postBuild();
00189 
00190         // Check typing timeout timer.
00191         /*virtual*/ void draw();
00192 
00193         /*virtual*/ void onClose(bool app_quitting = FALSE);
00194 
00195         // add target ids to the session. 
00196         // Return TRUE if successful, otherwise FALSE.
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         //callbacks for P2P muting and volume control
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         // Handle other participant in the session typing.
00250         void processIMTyping(const LLIMInfo* im_info, BOOL typing);
00251         static void chatFromLogFile(LLString line, void* userdata);
00252 
00253 private:
00254         // called by constructors
00255         void init(const LLString& session_label);
00256 
00257         // Called by UI methods.
00258         void sendMsg();
00259 
00260         // for adding agents via the UI. Return TRUE if possible, do it if 
00261         BOOL dropCallingCard(LLInventoryItem* item, BOOL drop);
00262         BOOL dropCategory(LLInventoryCategory* category, BOOL drop);
00263 
00264         // test if local agent can add agents.
00265         BOOL isInviteAllowed() const;
00266 
00267         // Called whenever the user starts or stops typing.
00268         // Sends the typing state to the other user if necessary.
00269         void setTyping(BOOL typing);
00270 
00271         // Add the "User is typing..." indicator.
00272         void addTypingIndicator(const std::string &name);
00273 
00274         // Remove the "User is typing..." indicator.
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         // The value of the mSessionUUID depends on how the IM session was started:
00286         //   one-on-one  ==> random id
00287         //   group ==> group_id
00288         //   inventory folder ==> folder item_id 
00289         //   911 ==> Gaurdian_Angel_Group_ID ^ gAgent.getID()
00290         LLUUID mSessionUUID;
00291 
00292         LLVoiceChannel* mVoiceChannel;
00293 
00294         BOOL mSessionInitialized;
00295         LLSD mQueuedMsgsForInit;
00296 
00297         // The value mOtherParticipantUUID depends on how the IM session was started:
00298         //   one-on-one = recipient's id
00299         //   group ==> group_id
00300         //   inventory folder ==> first target id in list
00301         //   911 ==> sender
00302         LLUUID mOtherParticipantUUID;
00303         LLDynamicArray<LLUUID> mSessionInitialTargetIDs;
00304 
00305         EInstantMessage mDialog;
00306 
00307         // Are you currently typing?
00308         BOOL mTyping;
00309 
00310         // Is other user currently typing?
00311         BOOL mOtherTyping;
00312 
00313         // name of other user who is currently typing
00314         std::string mOtherTypingName;
00315 
00316         // Where does the "User is typing..." line start?
00317         S32 mTypingLineStartIndex;
00318         // Where does the "Starting session..." line start?
00319         S32 mSessionStartMsgPos;
00320         
00321         BOOL mSentTypingState;
00322 
00323         BOOL mShowSpeakersOnConnect;
00324 
00325         BOOL mAutoConnect;
00326 
00327         LLIMSpeakerMgr* mSpeakers;
00328         LLPanelActiveSpeakers* mSpeakerPanel;
00329         
00330         // Optimization:  Don't send "User is typing..." until the
00331         // user has actually been typing for a little while.  Prevents
00332         // extra IMs for brief "lol" type utterences.
00333         LLFrameTimer mFirstKeystrokeTimer;
00334 
00335         // Timer to detect when user has stopped typing.
00336         LLFrameTimer mLastKeystrokeTimer;
00337 
00338         void disableWhileSessionStarting();
00339 };
00340 
00341 
00342 #endif  // LL_IMPANEL_H

Generated on Thu Jul 1 06:08:44 2010 for Second Life Viewer by  doxygen 1.4.7