Repository navigation
Expand file tree
/
Copy pathIm.java
More file actions
2352 lines (2028 loc) · 77.1 KB
/
Copy pathIm.java
File metadata and controls
2352 lines (2028 loc) · 77.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.provider;
import android.content.ContentQueryMap;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.os.Handler;
import java.util.HashMap;
/**
* The GTalk provider stores all information about roster contacts, chat messages, presence, etc.
*
* @hide
*/
public class Im {
/**
* no public constructor since this is a utility class
*/
private Im() {}
/**
* The Columns for IM providers
*/
public interface ProviderColumns {
/**
* The name of the IM provider
* <P>Type: TEXT</P>
*/
String NAME = "name";
/**
* The full name of the provider
* <P>Type: TEXT</P>
*/
String FULLNAME = "fullname";
/**
* The category for the provider, used to form intent.
* <P>Type: TEXT</P>
*/
String CATEGORY = "category";
/**
* The url users should visit to create a new account for this provider
* <P>Type: TEXT</P>
*/
String SIGNUP_URL = "signup_url";
}
/**
* Known names corresponding to the {@link ProviderColumns#NAME} column
*/
public interface ProviderNames {
//
//NOTE: update Contacts.java with new providers when they're added.
//
String YAHOO = "Yahoo";
String GTALK = "GTalk";
String MSN = "MSN";
String ICQ = "ICQ";
String AIM = "AIM";
String XMPP = "XMPP";
String JABBER = "JABBER";
String SKYPE = "SKYPE";
String QQ = "QQ";
}
/**
* This table contains the IM providers
*/
public static final class Provider implements BaseColumns, ProviderColumns {
private Provider() {}
public static final long getProviderIdForName(ContentResolver cr, String providerName) {
String[] selectionArgs = new String[1];
selectionArgs[0] = providerName;
Cursor cursor = cr.query(CONTENT_URI,
PROVIDER_PROJECTION,
NAME+"=?",
selectionArgs, null);
long retVal = 0;
try {
if (cursor.moveToFirst()) {
retVal = cursor.getLong(cursor.getColumnIndexOrThrow(_ID));
}
} finally {
cursor.close();
}
return retVal;
}
public static final String getProviderNameForId(ContentResolver cr, long providerId) {
Cursor cursor = cr.query(CONTENT_URI,
PROVIDER_PROJECTION,
_ID + "=" + providerId,
null, null);
String retVal = null;
try {
if (cursor.moveToFirst()) {
retVal = cursor.getString(cursor.getColumnIndexOrThrow(NAME));
}
} finally {
cursor.close();
}
return retVal;
}
private static final String[] PROVIDER_PROJECTION = new String[] {
_ID,
NAME
};
public static final String ACTIVE_ACCOUNT_ID = "account_id";
public static final String ACTIVE_ACCOUNT_USERNAME = "account_username";
public static final String ACTIVE_ACCOUNT_PW = "account_pw";
public static final String ACTIVE_ACCOUNT_LOCKED = "account_locked";
public static final String ACTIVE_ACCOUNT_KEEP_SIGNED_IN = "account_keepSignedIn";
public static final String ACCOUNT_PRESENCE_STATUS = "account_presenceStatus";
public static final String ACCOUNT_CONNECTION_STATUS = "account_connStatus";
/**
* The content:// style URL for this table
*/
public static final Uri CONTENT_URI =
Uri.parse("content://com.google.android.providers.talk/providers");
public static final Uri CONTENT_URI_WITH_ACCOUNT =
Uri.parse("content://com.google.android.providers.talk/providers/account");
/**
* The MIME type of {@link #CONTENT_URI} providing a directory of
* people.
*/
public static final String CONTENT_TYPE =
"vnd.android.cursor.dir/gtalk-providers";
public static final String CONTENT_ITEM_TYPE =
"vnd.android.cursor.item/gtalk-providers";
/**
* The default sort order for this table
*/
public static final String DEFAULT_SORT_ORDER = "name ASC";
}
/**
* The columns for IM accounts. There can be more than one account for each IM provider.
*/
public interface AccountColumns {
/**
* The name of the account
* <P>Type: TEXT</P>
*/
String NAME = "name";
/**
* The IM provider for this account
* <P>Type: INTEGER</P>
*/
String PROVIDER = "provider";
/**
* The username for this account
* <P>Type: TEXT</P>
*/
String USERNAME = "username";
/**
* The password for this account
* <P>Type: TEXT</P>
*/
String PASSWORD = "pw";
/**
* A boolean value indicates if the account is active.
* <P>Type: INTEGER</P>
*/
String ACTIVE = "active";
/**
* A boolean value indicates if the account is locked (not editable)
* <P>Type: INTEGER</P>
*/
String LOCKED = "locked";
/**
* A boolean value to indicate whether this account is kept signed in.
* <P>Type: INTEGER</P>
*/
String KEEP_SIGNED_IN = "keep_signed_in";
/**
* A boolean value indiciating the last login state for this account
* <P>Type: INTEGER</P>
*/
String LAST_LOGIN_STATE = "last_login_state";
}
/**
* This table contains the IM accounts.
*/
public static final class Account implements BaseColumns, AccountColumns {
private Account() {}
public static final long getProviderIdForAccount(ContentResolver cr, long accountId) {
Cursor cursor = cr.query(CONTENT_URI,
PROVIDER_PROJECTION,
_ID + "=" + accountId,
null /* selection args */,
null /* sort order */);
long providerId = 0;
try {
if (cursor.moveToFirst()) {
providerId = cursor.getLong(PROVIDER_COLUMN);
}
} finally {
cursor.close();
}
return providerId;
}
private static final String[] PROVIDER_PROJECTION = new String[] { PROVIDER };
private static final int PROVIDER_COLUMN = 0;
/**
* The content:// style URL for this table
*/
public static final Uri CONTENT_URI =
Uri.parse("content://com.google.android.providers.talk/accounts");
/**
* The MIME type of {@link #CONTENT_URI} providing a directory of
* account.
*/
public static final String CONTENT_TYPE =
"vnd.android.cursor.dir/gtalk-accounts";
/**
* The MIME type of a {@link #CONTENT_URI} subdirectory of a single
* account.
*/
public static final String CONTENT_ITEM_TYPE =
"vnd.android.cursor.item/gtalk-accounts";
/**
* The default sort order for this table
*/
public static final String DEFAULT_SORT_ORDER = "name ASC";
}
/**
* Connection status
*/
public interface ConnectionStatus {
/**
* The connection is offline, not logged in.
*/
int OFFLINE = 0;
/**
* The connection is attempting to connect.
*/
int CONNECTING = 1;
/**
* The connection is suspended due to network not available.
*/
int SUSPENDED = 2;
/**
* The connection is logged in and online.
*/
int ONLINE = 3;
}
public interface AccountStatusColumns {
/**
* account id
* <P>Type: INTEGER</P>
*/
String ACCOUNT = "account";
/**
* User's presence status, see definitions in {#link CommonPresenceColumn}
* <P>Type: INTEGER</P>
*/
String PRESENCE_STATUS = "presenceStatus";
/**
* The connection status of this account, see {#link ConnectionStatus}
* <P>Type: INTEGER</P>
*/
String CONNECTION_STATUS = "connStatus";
}
public static final class AccountStatus implements BaseColumns, AccountStatusColumns {
/**
* The content:// style URL for this table
*/
public static final Uri CONTENT_URI =
Uri.parse("content://com.google.android.providers.talk/accountStatus");
/**
* The MIME type of {@link #CONTENT_URI} providing a directory of account status.
*/
public static final String CONTENT_TYPE =
"vnd.android.cursor.dir/gtalk-account-status";
/**
* The MIME type of a {@link #CONTENT_URI} subdirectory of a single account status.
*/
public static final String CONTENT_ITEM_TYPE =
"vnd.android.cursor.item/gtalk-account-status";
/**
* The default sort order for this table
*/
public static final String DEFAULT_SORT_ORDER = "name ASC";
}
/**
* Columns from the Contacts table.
*/
public interface ContactsColumns {
/**
* The username
* <P>Type: TEXT</P>
*/
String USERNAME = "username";
/**
* The nickname or display name
* <P>Type: TEXT</P>
*/
String NICKNAME = "nickname";
/**
* The IM provider for this contact
* <P>Type: INTEGER</P>
*/
String PROVIDER = "provider";
/**
* The account (within a IM provider) for this contact
* <P>Type: INTEGER</P>
*/
String ACCOUNT = "account";
/**
* The contactList this contact belongs to
* <P>Type: INTEGER</P>
*/
String CONTACTLIST = "contactList";
/**
* Contact type
* <P>Type: INTEGER</P>
*/
String TYPE = "type";
/**
* normal IM contact
*/
int TYPE_NORMAL = 0;
/**
* temporary contact, someone not in the list of contacts that we
* subscribe presence for. Usually created because of the user is
* having a chat session with this contact.
*/
int TYPE_TEMPORARY = 1;
/**
* temporary contact created for group chat.
*/
int TYPE_GROUP = 2;
/**
* blocked contact.
*/
int TYPE_BLOCKED = 3;
/**
* the contact is hidden. The client should always display this contact to the user.
*/
int TYPE_HIDDEN = 4;
/**
* the contact is pinned. The client should always display this contact to the user.
*/
int TYPE_PINNED = 5;
/**
* Contact subscription status
* <P>Type: INTEGER</P>
*/
String SUBSCRIPTION_STATUS = "subscriptionStatus";
/**
* no pending subscription
*/
int SUBSCRIPTION_STATUS_NONE = 0;
/**
* requested to subscribe
*/
int SUBSCRIPTION_STATUS_SUBSCRIBE_PENDING = 1;
/**
* requested to unsubscribe
*/
int SUBSCRIPTION_STATUS_UNSUBSCRIBE_PENDING = 2;
/**
* Contact subscription type
* <P>Type: INTEGER </P>
*/
String SUBSCRIPTION_TYPE = "subscriptionType";
/**
* The user and contact have no interest in each other's presence.
*/
int SUBSCRIPTION_TYPE_NONE = 0;
/**
* The user wishes to stop receiving presence updates from the contact.
*/
int SUBSCRIPTION_TYPE_REMOVE = 1;
/**
* The user is interested in receiving presence updates from the contact.
*/
int SUBSCRIPTION_TYPE_TO = 2;
/**
* The contact is interested in receiving presence updates from the user.
*/
int SUBSCRIPTION_TYPE_FROM = 3;
/**
* The user and contact have a mutual interest in each other's presence.
*/
int SUBSCRIPTION_TYPE_BOTH = 4;
/**
* This is a special type reserved for pending subscription requests
*/
int SUBSCRIPTION_TYPE_INVITATIONS = 5;
/**
* Quick Contact: derived from Google Contact Extension's "message_count" attribute.
* <P>Type: INTEGER</P>
*/
String QUICK_CONTACT = "qc";
/**
* Google Contact Extension attribute
*
* Rejected: a boolean value indicating whether a subscription request from
* this client was ever rejected by the user. "true" indicates that it has.
* This is provided so that a client can block repeated subscription requests.
* <P>Type: INTEGER</P>
*/
String REJECTED = "rejected";
/**
* Off The Record status: 0 for disabled, 1 for enabled
* <P>Type: INTEGER </P>
*/
String OTR = "otr";
}
/**
* This defines the different type of values of {@link ContactsColumns#OTR}
*/
public interface OffTheRecordType {
/*
* Off the record not turned on
*/
int DISABLED = 0;
/**
* Off the record turned on, but we don't know who turned it on
*/
int ENABLED = 1;
/**
* Off the record turned on by the user
*/
int ENABLED_BY_USER = 2;
/**
* Off the record turned on by the buddy
*/
int ENABLED_BY_BUDDY = 3;
};
/**
* This table contains contacts.
*/
public static final class Contacts implements BaseColumns,
ContactsColumns, PresenceColumns, ChatsColumns {
/**
* no public constructor since this is a utility class
*/
private Contacts() {}
/**
* The content:// style URL for this table
*/
public static final Uri CONTENT_URI =
Uri.parse("content://com.google.android.providers.talk/contacts");
/**
* The content:// style URL for contacts joined with presence
*/
public static final Uri CONTENT_URI_WITH_PRESENCE =
Uri.parse("content://com.google.android.providers.talk/contactsWithPresence");
/**
* The content:// style URL for barebone contacts, not joined with any other table
*/
public static final Uri CONTENT_URI_CONTACTS_BAREBONE =
Uri.parse("content://com.google.android.providers.talk/contactsBarebone");
/**
* The content:// style URL for contacts who have an open chat session
*/
public static final Uri CONTENT_URI_CHAT_CONTACTS =
Uri.parse("content://com.google.android.providers.talk/contacts_chatting");
/**
* The content:// style URL for contacts who have been blocked
*/
public static final Uri CONTENT_URI_BLOCKED_CONTACTS =
Uri.parse("content://com.google.android.providers.talk/contacts/blocked");
/**
* The content:// style URL for contacts by provider and account
*/
public static final Uri CONTENT_URI_CONTACTS_BY =
Uri.parse("content://com.google.android.providers.talk/contacts");
/**
* The content:// style URL for contacts by provider and account,
* and who have an open chat session
*/
public static final Uri CONTENT_URI_CHAT_CONTACTS_BY =
Uri.parse("content://com.google.android.providers.talk/contacts/chatting");
/**
* The content:// style URL for contacts by provider and account,
* and who are online
*/
public static final Uri CONTENT_URI_ONLINE_CONTACTS_BY =
Uri.parse("content://com.google.android.providers.talk/contacts/online");
/**
* The content:// style URL for contacts by provider and account,
* and who are offline
*/
public static final Uri CONTENT_URI_OFFLINE_CONTACTS_BY =
Uri.parse("content://com.google.android.providers.talk/contacts/offline");
/**
* The content:// style URL for operations on bulk contacts
*/
public static final Uri BULK_CONTENT_URI =
Uri.parse("content://com.google.android.providers.talk/bulk_contacts");
/**
* The content:// style URL for the count of online contacts in each
* contact list by provider and account.
*/
public static final Uri CONTENT_URI_ONLINE_COUNT =
Uri.parse("content://com.google.android.providers.talk/contacts/onlineCount");
/**
* The MIME type of {@link #CONTENT_URI} providing a directory of
* people.
*/
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/gtalk-contacts";
/**
* The MIME type of a {@link #CONTENT_URI} subdirectory of a single
* person.
*/
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/gtalk-contacts";
/**
* The default sort order for this table
*/
public static final String DEFAULT_SORT_ORDER =
"subscriptionType DESC, last_message_date DESC," +
" mode DESC, nickname COLLATE UNICODE ASC";
public static final String CHATS_CONTACT = "chats_contact";
public static final String AVATAR_HASH = "avatars_hash";
public static final String AVATAR_DATA = "avatars_data";
}
/**
* Columns from the ContactList table.
*/
public interface ContactListColumns {
String NAME = "name";
String PROVIDER = "provider";
String ACCOUNT = "account";
}
/**
* This table contains the contact lists.
*/
public static final class ContactList implements BaseColumns,
ContactListColumns {
private ContactList() {}
/**
* The content:// style URL for this table
*/
public static final Uri CONTENT_URI =
Uri.parse("content://com.google.android.providers.talk/contactLists");
/**
* The MIME type of {@link #CONTENT_URI} providing a directory of
* people.
*/
public static final String CONTENT_TYPE =
"vnd.android.cursor.dir/gtalk-contactLists";
/**
* The MIME type of a {@link #CONTENT_URI} subdirectory of a single
* person.
*/
public static final String CONTENT_ITEM_TYPE =
"vnd.android.cursor.item/gtalk-contactLists";
/**
* The default sort order for this table
*/
public static final String DEFAULT_SORT_ORDER = "name COLLATE UNICODE ASC";
public static final String PROVIDER_NAME = "provider_name";
public static final String ACCOUNT_NAME = "account_name";
}
/**
* Columns from the BlockedList table.
*/
public interface BlockedListColumns {
/**
* The username of the blocked contact.
* <P>Type: TEXT</P>
*/
String USERNAME = "username";
/**
* The nickname of the blocked contact.
* <P>Type: TEXT</P>
*/
String NICKNAME = "nickname";
/**
* The provider id of the blocked contact.
* <P>Type: INT</P>
*/
String PROVIDER = "provider";
/**
* The account id of the blocked contact.
* <P>Type: INT</P>
*/
String ACCOUNT = "account";
}
/**
* This table contains blocked lists
*/
public static final class BlockedList implements BaseColumns, BlockedListColumns {
private BlockedList() {}
/**
* The content:// style URL for this table
*/
public static final Uri CONTENT_URI =
Uri.parse("content://com.google.android.providers.talk/blockedList");
/**
* The MIME type of {@link #CONTENT_URI} providing a directory of
* people.
*/
public static final String CONTENT_TYPE =
"vnd.android.cursor.dir/gtalk-blockedList";
/**
* The MIME type of a {@link #CONTENT_URI} subdirectory of a single
* person.
*/
public static final String CONTENT_ITEM_TYPE =
"vnd.android.cursor.item/gtalk-blockedList";
/**
* The default sort order for this table
*/
public static final String DEFAULT_SORT_ORDER = "nickname ASC";
public static final String PROVIDER_NAME = "provider_name";
public static final String ACCOUNT_NAME = "account_name";
public static final String AVATAR_DATA = "avatars_data";
}
/**
* Columns from the contactsEtag table
*/
public interface ContactsEtagColumns {
/**
* The roster etag, computed by the server, stored on the client. There is one etag
* per account roster.
* <P>Type: TEXT</P>
*/
String ETAG = "etag";
/**
* The OTR etag, computed by the server, stored on the client. There is one OTR etag
* per account roster.
* <P>Type: TEXT</P>
*/
String OTR_ETAG = "otr_etag";
/**
* The account id for the etag.
* <P> Type: INTEGER </P>
*/
String ACCOUNT = "account";
}
public static final class ContactsEtag implements BaseColumns, ContactsEtagColumns {
private ContactsEtag() {}
public static final Cursor query(ContentResolver cr,
String[] projection) {
return cr.query(CONTENT_URI, projection, null, null, null);
}
public static final Cursor query(ContentResolver cr,
String[] projection, String where, String orderBy) {
return cr.query(CONTENT_URI, projection, where,
null, orderBy == null ? null : orderBy);
}
public static final String getRosterEtag(ContentResolver resolver, long accountId) {
String retVal = null;
Cursor c = resolver.query(CONTENT_URI,
CONTACT_ETAG_PROJECTION,
ACCOUNT + "=" + accountId,
null /* selection args */,
null /* sort order */);
try {
if (c.moveToFirst()) {
retVal = c.getString(COLUMN_ETAG);
}
} finally {
c.close();
}
return retVal;
}
public static final String getOtrEtag(ContentResolver resolver, long accountId) {
String retVal = null;
Cursor c = resolver.query(CONTENT_URI,
CONTACT_OTR_ETAG_PROJECTION,
ACCOUNT + "=" + accountId,
null /* selection args */,
null /* sort order */);
try {
if (c.moveToFirst()) {
retVal = c.getString(COLUMN_OTR_ETAG);
}
} finally {
c.close();
}
return retVal;
}
private static final String[] CONTACT_ETAG_PROJECTION = new String[] {
Im.ContactsEtag.ETAG // 0
};
private static int COLUMN_ETAG = 0;
private static final String[] CONTACT_OTR_ETAG_PROJECTION = new String[] {
Im.ContactsEtag.OTR_ETAG // 0
};
private static int COLUMN_OTR_ETAG = 0;
/**
* The content:// style URL for this table
*/
public static final Uri CONTENT_URI =
Uri.parse("content://com.google.android.providers.talk/contactsEtag");
/**
* The MIME type of {@link #CONTENT_URI} providing a directory of
* people.
*/
public static final String CONTENT_TYPE =
"vnd.android.cursor.dir/gtalk-contactsEtag";
/**
* The MIME type of a {@link #CONTENT_URI} subdirectory of a single
* person.
*/
public static final String CONTENT_ITEM_TYPE =
"vnd.android.cursor.item/gtalk-contactsEtag";
}
/**
* Message type definition
*/
public interface MessageType {
/* sent message */
int OUTGOING = 0;
/* received message */
int INCOMING = 1;
/* presence became available */
int PRESENCE_AVAILABLE = 2;
/* presence became away */
int PRESENCE_AWAY = 3;
/* presence became DND (busy) */
int PRESENCE_DND = 4;
/* presence became unavailable */
int PRESENCE_UNAVAILABLE = 5;
/* the message is converted to a group chat */
int CONVERT_TO_GROUPCHAT = 6;
/* generic status */
int STATUS = 7;
/* the message cannot be sent now, but will be sent later */
int POSTPONED = 8;
/* off The Record status is turned off */
int OTR_IS_TURNED_OFF = 9;
/* off the record status is turned on */
int OTR_IS_TURNED_ON = 10;
/* off the record status turned on by user */
int OTR_TURNED_ON_BY_USER = 11;
/* off the record status turned on by buddy */
int OTR_TURNED_ON_BY_BUDDY = 12;
}
/**
* The common columns for messages table
*/
public interface MessageColumns {
/**
* The thread_id column stores the contact id of the contact the message belongs to.
* For groupchat messages, the thread_id stores the group id, which is the contact id
* of the temporary group contact created for the groupchat. So there should be no
* collision between groupchat message thread id and regular message thread id.
*/
String THREAD_ID = "thread_id";
/**
* The nickname. This is used for groupchat messages to indicate the participant's
* nickname. For non groupchat messages, this field should be left empty.
*/
String NICKNAME = "nickname";
/**
* The body
* <P>Type: TEXT</P>
*/
String BODY = "body";
/**
* The date this message is sent or received. This represents the display date for
* the message.
* <P>Type: INTEGER</P>
*/
String DATE = "date";
/**
* The real date for this message. While 'date' can be modified by the client
* to account for server time skew, the real_date is the original timestamp set
* by the server for incoming messages.
* <P>Type: INTEGER</P>
*/
String REAL_DATE = "real_date";
/**
* Message Type, see {@link MessageType}
* <P>Type: INTEGER</P>
*/
String TYPE = "type";
/**
* Error Code: 0 means no error.
* <P>Type: INTEGER </P>
*/
String ERROR_CODE = "err_code";
/**
* Error Message
* <P>Type: TEXT</P>
*/
String ERROR_MESSAGE = "err_msg";
/**
* Packet ID, auto assigned by the GTalkService for outgoing messages or the
* GTalk server for incoming messages. The packet id field is optional for messages,
* so it could be null.
* <P>Type: STRING</P>
*/
String PACKET_ID = "packet_id";
/**
* Is groupchat message or not
* <P>Type: INTEGER</P>
*/
String IS_GROUP_CHAT = "is_muc";
/**
* A hint that the UI should show the sent time of this message
* <P>Type: INTEGER</P>
*/
String DISPLAY_SENT_TIME = "show_ts";
}
/**
* This table contains messages.
*/
public static final class Messages implements BaseColumns, MessageColumns {
/**
* no public constructor since this is a utility class
*/
private Messages() {}
/**
* Gets the Uri to query messages by thread id.
*
* @param threadId the thread id of the message.
* @return the Uri
*/
public static final Uri getContentUriByThreadId(long threadId) {
Uri.Builder builder = CONTENT_URI_MESSAGES_BY_THREAD_ID.buildUpon();
ContentUris.appendId(builder, threadId);
return builder.build();
}
/**
* @deprecated
*
* Gets the Uri to query messages by account and contact.
*
* @param accountId the account id of the contact.
* @param username the user name of the contact.
* @return the Uri
*/
public static final Uri getContentUriByContact(long accountId, String username) {
Uri.Builder builder = CONTENT_URI_MESSAGES_BY_ACCOUNT_AND_CONTACT.buildUpon();
ContentUris.appendId(builder, accountId);
builder.appendPath(username);
return builder.build();
}
/**
* Gets the Uri to query messages by provider.
*
* @param providerId the service provider id.
* @return the Uri
*/
public static final Uri getContentUriByProvider(long providerId) {
Uri.Builder builder = CONTENT_URI_MESSAGES_BY_PROVIDER.buildUpon();
ContentUris.appendId(builder, providerId);
return builder.build();
}