All Classes Namespaces Files Functions Variables Groups
InstantMessaging.idl
1 /**
2  * @file Messages.idl
3  * @brief Work with instant messaging. Note that all communication is designed to be via WebSocket interface.
4  *
5  * @author Vaclav Purchart
6  */
7 
8 #import <Structures.idl>
9 
10 module kerio {
11 module jsonapi {
12 module webmail {
13 module im {
14 
15 // -- Presence types --
16 typedef long MessageId;
17 typedef long ConversationId;
18 typedef string ContactId;
19 
20 
21 enum Status {
22  available,
23  offline,
24  dnd,
25  away,
26  invisible
27 };
28 
29 struct Presence {
30  ContactId contactId;
31  Status status;
32  string text;
33  UtcDateTime date;
34 };
35 
36 typedef sequence<Presence> PresenceList;
37 
38 // -- Conversations --
39 
40 enum ConversationEvent {
41  Created, // when conversation id is created
42  Updated, // when message flows into conversation
43  Delivered, // when messages within this conversation were delivered
44  Read // when messages within this conversation has been read
45 };
46 
47 typedef sequence<ContactId> ContactIdList;
48 
49 struct Conversation {
50  ConversationId conversationId;
51  UtcDateTime lastActivity; // used to find RECENT conversations
52  MessageId sentLastDeliveredId; // all higher ids are undelivered (user-specific - messages from me)
53  MessageId sentLastReadId; // // all higher ids are undelivered (user-specific - messages from me)
54  MessageId receivedLastReadId; // all higher ids are undelivered (user-specific - message to me)
55  long receivedUnreadCount; // user-specific - message to me
56  ContactIdList contacts; // one for 1:1, more for groupchats
57  ConversationEvent event; // to notify other users/sessions about conversation activity
58  boolean muted;
59 };
60 
61 typedef sequence<Conversation> ConversationList;
62 
63 // -- Messages --
64 
65 enum MessageEvent {
66  active, // typing
67  inactive // stopped typing
68 };
69 
70 struct Message {
71  MessageId messageId;
72  string text;
73  MessageEvent event;
74  ConversationId to; // conversation ID
75  ContactId from;
76  UtcDateTime time; // filled by server
77 };
78 
79 typedef sequence<Message> MessageList;
80 
81 interface im {
82 
83  // -- Presence types --
84 
85  /**
86  * Every contact has its presence status updated on server according to contact activity or availability.
87  * Retrieve presence for users.
88  *
89  * @param list - list of statuses of given contacts (or all non-offilne contacts if input array is empty)
90  * @param contacts - (optional) list of all contacts
91  */
92  void getPresence(out PresenceList list, in kerio::web::KIdList contacts);
93 
94  /**
95  * Subsribe for presence changes. Presence status of all users are returned and changes then continuously pushed into client.
96  * Note that callback will be executed periodically as changes from server arrive.
97  *
98  * @param list - Presence status of all users. Offline users are always excluded. Missing means offline. (TODO)
99  */
100  void subscribePresence(out PresenceList list);
101 
102  /**
103  * Update own presence. Server than resend such status to all interested clients (subscribed) as a Presence with current date.
104  *
105  * @param status - new user status to be set (online, offline, ...)
106  * @param text - status text
107  */
108  void setPresence(in Status status, in string text);
109 
110 
111  // -- Conversations --
112 
113  /**
114  * Create new conversation (or return existing one)
115  *
116  * @param contacts - required conversation, one for 1:1, more for groupchats
117  * @param conversation - created conversation
118  */
119  void createConversation(out Conversation conversation, in ContactIdList contacts);
120 
121  /**
122  * It provides list of all conversations in which the current user participates and also subscribes for further changes.
123  *
124  * @param list - all conversations in which current user participes
125  */
126  void subscribeConversations(out ConversationList list);
127 
128  /**
129  * Set conversation as (un)muted for the current user
130  *
131  * @param conversationId - conversation to be set
132  * @param isMuted - true = conversation will be muted
133  */
134  void muteConversation(in ConversationId conversationId, in boolean mute);
135 
136  /**
137  * Set last read message in conversation for the current user
138  *
139  * @param conversationId - conversation to be set
140  * @param messageId - ID of last message which has been read
141  */
142  void readConversation(in ConversationId conversationId, in MessageId lastReadId);
143 
144  // -- Messages --
145 
146  /**
147  * Returns ordered list of messages from single conversation. The list is always ordered by messageId and always returns older messages than currentMessageId parameter
148  *
149  * @param conversationId - Identifier of a conversation.
150  * @param currentMessageId - Messages older than currentMessageId are returned
151  * @param count - Required messages count
152  * @param list - Ordered list of messages for given conversation
153  */
154  void getMessages(out MessageList list, in ConversationId conversationId, in MessageId currentMessageId, in long count);
155 
156  /**
157  * Returns ordered list of all new messages + required count of older messages from single conversation and also subscribes for continuous flow of changes. The list is always
158  * ordered by messageId. The continuous flow of messages includes all new, it is NOT filtered by query.
159  *
160  * @param conversationId - Identifier of a conversation
161  * @param currentMessageId - All newer (included currentMessageId) messages are returned + count of older messages
162  * @param count - Required older messages count
163  */
164  void subscribeMessages(out MessageList list, in ConversationId conversationId, in long currentMessageId, in long count);
165 
166  /**
167  * Stops listening on new messages within conversation.
168  *
169  * @param conversationId - Identifier of conversation to unsubscribe.
170  */
171  void unsubscribeMessages(in ConversationId conversationId);
172 
173  /**
174  * It sends a message into a conversation. Field 'message.to' must be known before sending a message. Client either have it or must asks for it.
175  *
176  * @param message - Message to be send. It already contains the destination (the 'to' field). It does not contain a 'messageId' as it is generated by server.
177  * @param messageId - Message id
178  * @param time - Time of message
179  * @param markAsRead - Message will be marked as read for to users.
180  */
181  void sendMessage(out MessageId messageId, out UtcDateTime time, in Message message, in boolean markAsRead);
182 };
183 
184 }; }; }; }; // end of namespace