diff options
Diffstat (limited to 'core/java/android/provider/Im.java')
-rw-r--r-- | core/java/android/provider/Im.java | 259 |
1 files changed, 168 insertions, 91 deletions
diff --git a/core/java/android/provider/Im.java b/core/java/android/provider/Im.java index 19ad158..c36f508 100644 --- a/core/java/android/provider/Im.java +++ b/core/java/android/provider/Im.java @@ -871,14 +871,22 @@ public class Im { } /** - * The common columns for both one-to-one chat messages or group chat messages. + * The common columns for messages table */ - public interface BaseMessageColumns { + public interface MessageColumns { /** - * The user this message belongs to - * <P>Type: TEXT</P> + * 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 CONTACT = "contact"; + 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 @@ -917,68 +925,193 @@ public class Im { * <P>Type: STRING</P> */ String PACKET_ID = "packet_id"; - } - - /** - * Columns from the Messages table. - */ - public interface MessagesColumns extends BaseMessageColumns{ - /** - * The provider id - * <P> Type: INTEGER </P> - */ - String PROVIDER = "provider"; /** - * The account id - * <P> Type: INTEGER </P> + * Is groupchat message or not + * <P>Type: INTEGER</P> */ - String ACCOUNT = "account"; + String IS_GROUP_CHAT = "is_muc"; } /** * This table contains messages. */ - public static final class Messages implements BaseColumns, MessagesColumns { + 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 contact. + * 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 providerId the provider id of the 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 providerId, - long accountId, String username) { - Uri.Builder builder = CONTENT_URI_MESSAGES_BY.buildUpon(); + 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(); + } + + /** + * Gets the Uri to query off the record messages by account. + * + * @param accountId the account id. + * @return the Uri + */ + public static final Uri getContentUriByAccount(long accountId) { + Uri.Builder builder = CONTENT_URI_BY_ACCOUNT.buildUpon(); + ContentUris.appendId(builder, accountId); + return builder.build(); + } + + /** + * Gets the Uri to query off the record messages by thread id. + * + * @param threadId the thread id of the message. + * @return the Uri + */ + public static final Uri getOtrMessagesContentUriByThreadId(long threadId) { + Uri.Builder builder = OTR_MESSAGES_CONTENT_URI_BY_THREAD_ID.buildUpon(); + ContentUris.appendId(builder, threadId); + return builder.build(); + } + + /** + * @deprecated + * + * Gets the Uri to query off the record 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 getOtrMessagesContentUriByContact(long accountId, String username) { + Uri.Builder builder = OTR_MESSAGES_CONTENT_URI_BY_ACCOUNT_AND_CONTACT.buildUpon(); ContentUris.appendId(builder, accountId); builder.appendPath(username); return builder.build(); } /** + * Gets the Uri to query off the record messages by provider. + * + * @param providerId the service provider id. + * @return the Uri + */ + public static final Uri getOtrMessagesContentUriByProvider(long providerId) { + Uri.Builder builder = OTR_MESSAGES_CONTENT_URI_BY_PROVIDER.buildUpon(); + ContentUris.appendId(builder, providerId); + return builder.build(); + } + + /** + * Gets the Uri to query off the record messages by account. + * + * @param accountId the account id. + * @return the Uri + */ + public static final Uri getOtrMessagesContentUriByAccount(long accountId) { + Uri.Builder builder = OTR_MESSAGES_CONTENT_URI_BY_ACCOUNT.buildUpon(); + ContentUris.appendId(builder, accountId); + return builder.build(); + } + + /** * The content:// style URL for this table */ public static final Uri CONTENT_URI = - Uri.parse("content://im/messages"); + Uri.parse("content://im/messages"); + + /** + * The content:// style URL for messages by thread id + */ + public static final Uri CONTENT_URI_MESSAGES_BY_THREAD_ID = + Uri.parse("content://im/messagesByThreadId"); + + /** + * The content:// style URL for messages by account and contact + */ + public static final Uri CONTENT_URI_MESSAGES_BY_ACCOUNT_AND_CONTACT = + Uri.parse("content://im/messagesByAcctAndContact"); + + /** + * The content:// style URL for messages by provider + */ + public static final Uri CONTENT_URI_MESSAGES_BY_PROVIDER = + Uri.parse("content://im/messagesByProvider"); + + /** + * The content:// style URL for messages by account + */ + public static final Uri CONTENT_URI_BY_ACCOUNT = + Uri.parse("content://im/messagesByAccount"); + + /** + * The content:// style url for off the record messages + */ + public static final Uri OTR_MESSAGES_CONTENT_URI = + Uri.parse("content://im/otrMessages"); /** - * The content:// style URL for messages by provider and account + * The content:// style url for off the record messages by thread id */ - public static final Uri CONTENT_URI_MESSAGES_BY = - Uri.parse("content://im/messagesBy"); + public static final Uri OTR_MESSAGES_CONTENT_URI_BY_THREAD_ID = + Uri.parse("content://im/otrMessagesByThreadId"); + + /** + * The content:// style url for off the record messages by account and contact + */ + public static final Uri OTR_MESSAGES_CONTENT_URI_BY_ACCOUNT_AND_CONTACT = + Uri.parse("content://im/otrMessagesByAcctAndContact"); + + /** + * The content:// style URL for off the record messages by provider + */ + public static final Uri OTR_MESSAGES_CONTENT_URI_BY_PROVIDER = + Uri.parse("content://im/otrMessagesByProvider"); + + /** + * The content:// style URL for off the record messages by account + */ + public static final Uri OTR_MESSAGES_CONTENT_URI_BY_ACCOUNT = + Uri.parse("content://im/otrMessagesByAccount"); /** * The MIME type of {@link #CONTENT_URI} providing a directory of * people. */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-messages"; + public static final String CONTENT_TYPE = + "vnd.android.cursor.dir/im-messages"; /** * The MIME type of a {@link #CONTENT_URI} subdirectory of a single @@ -992,6 +1125,11 @@ public class Im { */ public static final String DEFAULT_SORT_ORDER = "date ASC"; + /** + * The "contact" column. This is not a real column in the messages table, but a + * temoprary column created when querying for messages (joined with the contacts table) + */ + public static final String CONTACT = "contact"; } /** @@ -1119,67 +1257,6 @@ public class Im { } /** - * Columns from the GroupMessages table - */ - public interface GroupMessageColumns extends BaseMessageColumns { - /** - * The group this message belongs to - * <p>Type: TEXT</p> - */ - String GROUP = "groupId"; - } - - /** - * This table contains group messages. - */ - public final static class GroupMessages implements BaseColumns, - GroupMessageColumns { - private GroupMessages() {} - - /** - * Gets the Uri to query group messages by group. - * - * @param groupId the group id. - * @return the Uri - */ - public static final Uri getContentUriByGroup(long groupId) { - Uri.Builder builder = CONTENT_URI_GROUP_MESSAGES_BY.buildUpon(); - ContentUris.appendId(builder, groupId); - return builder.build(); - } - - /** - * The content:// style URL for this table - */ - public static final Uri CONTENT_URI = - Uri.parse("content://im/groupMessages"); - - /** - * The content:// style URL for group messages by provider and account - */ - public static final Uri CONTENT_URI_GROUP_MESSAGES_BY = - Uri.parse("content://im/groupMessagesBy"); - - /** - * The MIME type of {@link #CONTENT_URI} providing a directory of - * group messages. - */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-groupMessages"; - - /** - * The MIME type of a {@link #CONTENT_URI} subdirectory of a single - * group message. - */ - public static final String CONTENT_ITEM_TYPE = - "vnd.android.cursor.item/im-groupMessages"; - - /** - * The default sort order for this table - */ - public static final String DEFAULT_SORT_ORDER = "date ASC"; - } - - /** * Columns from the Avatars table */ public interface AvatarsColumns { |