PageRenderTime 18ms CodeModel.GetById 1ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmessage/llinstantmessage.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 322 lines | 172 code | 60 blank | 90 comment | 0 complexity | b9f9553b1597dceea29f93a054e31482 MD5 | raw file
  1/** 
  2 * @file llinstantmessage.h
  3 * @brief Constants and declarations used by instant messages. 
  4 *
  5 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLINSTANTMESSAGE_H
 28#define LL_LLINSTANTMESSAGE_H
 29
 30#include "llhost.h"
 31#include "lluuid.h"
 32#include "llsd.h"
 33#include "llrefcount.h"
 34#include "llpointer.h"
 35#include "v3math.h"
 36
 37class LLMessageSystem;
 38
 39// The ImprovedInstantMessage only supports 8 bits in the "Dialog"
 40// field, so don't go past the byte boundary
 41enum EInstantMessage
 42{
 43	// default. ID is meaningless, nothing in the binary bucket.
 44	IM_NOTHING_SPECIAL = 0,
 45
 46	// pops a messagebox with a single OK button
 47	IM_MESSAGEBOX = 1,
 48
 49	// pops a countdown messagebox with a single OK button
 50	// IM_MESSAGEBOX_COUNTDOWN = 2,
 51
 52	// You've been invited to join a group.
 53	// ID is the group id.
 54
 55	// The binary bucket contains a null terminated string
 56	// representation of the officer/member status and join cost for
 57	// the invitee. (bug # 7672) The format is 1 byte for
 58	// officer/member (O for officer, M for member), and as many bytes
 59	// as necessary for cost.
 60	IM_GROUP_INVITATION = 3,
 61
 62	// Inventory offer.
 63	// ID is the transaction id
 64	// Binary bucket is a list of inventory uuid and type. 
 65	IM_INVENTORY_OFFERED = 4,
 66	IM_INVENTORY_ACCEPTED = 5,
 67	IM_INVENTORY_DECLINED = 6,
 68
 69	// Group vote
 70	// Name is name of person who called vote.
 71	// ID is vote ID used for internal tracking
 72	// TODO: _DEPRECATED suffix as part of vote removal - DEV-24856
 73	IM_GROUP_VOTE = 7,
 74
 75	// Group message
 76	// This means that the message is meant for everyone in the
 77	// agent's group. This will result in a database query to find all
 78	// participants and start an im session.
 79	IM_GROUP_MESSAGE_DEPRECATED = 8,
 80
 81	// Task inventory offer.
 82	// ID is the transaction id
 83	// Binary bucket is a (mostly) complete packed inventory item
 84	IM_TASK_INVENTORY_OFFERED = 9,
 85	IM_TASK_INVENTORY_ACCEPTED = 10,
 86	IM_TASK_INVENTORY_DECLINED = 11,
 87
 88	// Copied as pending, type LL_NOTHING_SPECIAL, for new users
 89	// used by offline tools
 90	IM_NEW_USER_DEFAULT = 12,
 91
 92	//
 93	// session based messaging - the way that people usually actually
 94	// communicate with each other.
 95	//
 96
 97	// Invite users to a session.
 98	IM_SESSION_INVITE = 13,
 99
100	IM_SESSION_P2P_INVITE = 14,
101
102	// start a session with your gruop
103	IM_SESSION_GROUP_START = 15,
104
105	// start a session without a calling card (finder or objects)
106	IM_SESSION_CONFERENCE_START = 16,
107
108	// send a message to a session.
109	IM_SESSION_SEND = 17,
110
111	// leave a session
112	IM_SESSION_LEAVE = 18,
113
114	// an instant message from an object - for differentiation on the
115	// viewer, since you can't IM an object yet.
116	IM_FROM_TASK = 19,
117
118	// sent an IM to a busy user, this is the auto response
119	IM_BUSY_AUTO_RESPONSE = 20,
120
121	// Shows the message in the console and chat history
122	IM_CONSOLE_AND_CHAT_HISTORY = 21,
123
124	// IM Types used for luring your friends
125	IM_LURE_USER = 22,
126	IM_LURE_ACCEPTED = 23,
127	IM_LURE_DECLINED = 24,
128	IM_GODLIKE_LURE_USER = 25,
129	IM_YET_TO_BE_USED = 26,
130
131	// IM that notifie of a new group election.
132	// Name is name of person who called vote.
133	// ID is election ID used for internal tracking
134	IM_GROUP_ELECTION_DEPRECATED = 27,
135
136	// IM to tell the user to go to an URL. Put a text message in the
137	// message field, and put the url with a trailing \0 in the binary
138	// bucket.
139	IM_GOTO_URL = 28,
140
141	// a message generated by a script which we don't want to
142	// be sent through e-mail.  Similar to IM_FROM_TASK, but
143	// it is shown as an alert on the viewer.
144	IM_FROM_TASK_AS_ALERT = 31,
145
146	// IM from group officer to all group members.
147	IM_GROUP_NOTICE = 32,
148	IM_GROUP_NOTICE_INVENTORY_ACCEPTED = 33,
149	IM_GROUP_NOTICE_INVENTORY_DECLINED = 34,
150
151	IM_GROUP_INVITATION_ACCEPT = 35,
152	IM_GROUP_INVITATION_DECLINE = 36,
153
154	IM_GROUP_NOTICE_REQUESTED = 37,
155
156	IM_FRIENDSHIP_OFFERED = 38,
157	IM_FRIENDSHIP_ACCEPTED = 39,
158	IM_FRIENDSHIP_DECLINED_DEPRECATED = 40,
159
160	IM_TYPING_START = 41,
161	IM_TYPING_STOP = 42,
162
163	IM_COUNT
164};
165
166
167// Hooks for quickly hacking in experimental admin debug messages 
168// without needing to recompile the viewer
169// *NOTE: This functionality has been moved to be a string based
170// operation so that we don't even have to do a full recompile. This
171// enumeration will be phased out soon.
172enum EGodlikeRequest
173{
174	GOD_WANTS_NOTHING,
175
176	// for requesting physics information about an object
177	GOD_WANTS_PHYSICS_INFO,
178	
179	// two unused requests that can be appropriated for debug 
180	// purposes (no viewer recompile necessary)
181	GOD_WANTS_FOO,
182	GOD_WANTS_BAR,
183
184	// to dump simulator terrain data to terrain.raw file
185	GOD_WANTS_TERRAIN_SAVE,
186	// to load simulator terrain data from terrain.raw file
187	GOD_WANTS_TERRAIN_LOAD,
188
189	GOD_WANTS_TOGGLE_AVATAR_GEOMETRY,	// HACK for testing new avatar geom
190
191	// real-time telehub operations
192	GOD_WANTS_TELEHUB_INFO,
193	GOD_WANTS_CONNECT_TELEHUB,
194	GOD_WANTS_DELETE_TELEHUB,
195	GOD_WANTS_ADD_TELEHUB_SPAWNPOINT,
196	GOD_WANTS_REMOVE_TELEHUB_SPAWNPOINT,
197
198};
199
200enum EIMSource
201{
202	IM_FROM_VIEWER,
203	IM_FROM_DATASERVER,
204	IM_FROM_SIM
205};
206
207extern const U8 IM_ONLINE;
208extern const U8 IM_OFFLINE;
209
210extern const S32 VOTE_YES;
211extern const S32 VOTE_NO;
212extern const S32 VOTE_ABSTAIN;
213
214extern const S32 VOTE_MAJORITY;
215extern const S32 VOTE_SUPER_MAJORITY;
216extern const S32 VOTE_UNANIMOUS;
217
218extern const char EMPTY_BINARY_BUCKET[];
219extern const S32 EMPTY_BINARY_BUCKET_SIZE;
220
221extern const U32 NO_TIMESTAMP;
222extern const std::string SYSTEM_FROM;
223extern const std::string INTERACTIVE_SYSTEM_FROM;
224
225// Number of retry attempts on sending the im.
226extern const S32 IM_TTL;
227
228
229class LLIMInfo : public LLRefCount
230{
231protected:
232	LLIMInfo();
233	~LLIMInfo();
234
235public:
236	LLIMInfo(LLMessageSystem* msg, 
237			EIMSource source = IM_FROM_SIM, 
238			S32 ttl = IM_TTL);
239
240	LLIMInfo(
241		const LLUUID& from_id,
242		BOOL from_group,
243		const LLUUID& to_id,
244		EInstantMessage im_type, 
245		const std::string& name,
246		const std::string& message,
247		const LLUUID& id,
248		U32 parent_estate_id,
249		const LLUUID& region_id,
250		const LLVector3& position,
251		LLSD data,
252		U8 offline,
253		U32 timestamp,
254		EIMSource source,
255		S32 ttl = IM_TTL);
256
257	void packInstantMessage(LLMessageSystem* msg) const;
258	void packMessageBlock(LLMessageSystem* msg) const;
259	void unpackMessageBlock(LLMessageSystem* msg);
260	LLPointer<LLIMInfo> clone();
261public:
262	LLUUID mFromID;
263	BOOL mFromGroup;
264	LLUUID mToID;
265	U32 mParentEstateID;
266	LLUUID mRegionID;
267	LLVector3 mPosition;
268	U8 mOffline;
269	bool mViewerThinksToIsOnline;
270	EInstantMessage mIMType; 
271	LLUUID mID;
272	U32 mTimeStamp;
273	std::string mName;
274	std::string mMessage;
275	LLSD mData;
276
277	EIMSource mSource;
278	S32 mTTL;
279};
280
281LLPointer<LLIMInfo> llsd_to_im_info(const LLSD& im_info_sd);
282LLSD im_info_to_llsd(LLPointer<LLIMInfo> im_info);
283
284void pack_instant_message(
285	LLMessageSystem* msgsystem,
286	const LLUUID& from_id,
287	BOOL from_group,
288	const LLUUID& session_id,
289	const LLUUID& to_id,
290	const std::string& name,
291	const std::string& message,
292	U8 offline = IM_ONLINE,
293	EInstantMessage dialog = IM_NOTHING_SPECIAL,
294	const LLUUID& id = LLUUID::null,
295	U32 parent_estate_id = 0,
296	const LLUUID& region_id = LLUUID::null,
297	const LLVector3& position = LLVector3::zero,
298	U32 timestamp = NO_TIMESTAMP, 
299	const U8* binary_bucket = (U8*)EMPTY_BINARY_BUCKET,
300	S32 binary_bucket_size = EMPTY_BINARY_BUCKET_SIZE);
301
302void pack_instant_message_block(
303	LLMessageSystem* msgsystem,
304	const LLUUID& from_id,
305	BOOL from_group,
306	const LLUUID& session_id,
307	const LLUUID& to_id,
308	const std::string& name,
309	const std::string& message,
310	U8 offline = IM_ONLINE,
311	EInstantMessage dialog = IM_NOTHING_SPECIAL,
312	const LLUUID& id = LLUUID::null,
313	U32 parent_estate_id = 0,
314	const LLUUID& region_id = LLUUID::null,
315	const LLVector3& position = LLVector3::zero,
316	U32 timestamp = NO_TIMESTAMP, 
317	const U8* binary_bucket = (U8*)EMPTY_BINARY_BUCKET,
318	S32 binary_bucket_size = EMPTY_BINARY_BUCKET_SIZE);
319
320
321#endif // LL_LLINSTANTMESSAGE_H
322