summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-04-29 14:32:10 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-04-29 14:32:10 -0700
commitb7a64360fa5bc7c02527c0a4c9ff1d1d3c7c672c (patch)
treee2b3a4fabccd4dd97028a92c48566a83628ed076
parente82dc4205285a40d6c2227e362c30ce24c96a552 (diff)
parentb3624b96803d7e7979a3c3814610dd741423571c (diff)
downloadframeworks_base-b7a64360fa5bc7c02527c0a4c9ff1d1d3c7c672c.zip
frameworks_base-b7a64360fa5bc7c02527c0a4c9ff1d1d3c7c672c.tar.gz
frameworks_base-b7a64360fa5bc7c02527c0a4c9ff1d1d3c7c672c.tar.bz2
Merge change 711
* changes: store contact id in messages table instead of contact name string; merge messages and group messages tables.
-rw-r--r--core/java/android/provider/Im.java193
1 files changed, 101 insertions, 92 deletions
diff --git a/core/java/android/provider/Im.java b/core/java/android/provider/Im.java
index 19ad158..898c321 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,64 +925,121 @@ 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();
- ContentUris.appendId(builder, providerId);
+ 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 server 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 groupchat messages by thread id.
+ *
+ * @param threadId the thread id of the groupchat message.
+ * @return the Uri
+ */
+ public static final Uri getGroupChatContentUriByThreadId(long threadId) {
+ Uri.Builder builder = GROUP_CHAT_CONTENT_URI_MESSAGES_BY_THREAD_ID.buildUpon();
+ ContentUris.appendId(builder, threadId);
+ return builder.build();
+ }
+
+ /**
* The content:// style URL for this table
*/
- public static final Uri CONTENT_URI =
- Uri.parse("content://im/messages");
+ public static final Uri CONTENT_URI = 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 groupchat messages.
+ */
+ public static final Uri GROUP_CHAT_CONTENT_URI = Uri.parse("content://im/groupMessages");
/**
- * The content:// style URL for messages by provider and account
+ * The content:// style URL for groupchat messages by thread id
*/
- public static final Uri CONTENT_URI_MESSAGES_BY =
- Uri.parse("content://im/messagesBy");
+ public static final Uri GROUP_CHAT_CONTENT_URI_MESSAGES_BY_THREAD_ID =
+ Uri.parse("content://im/groupMessagesByThreadId");
/**
+ * The MIME type of {@link #CONTENT_URI} providing a directory of groupchat messages.
+ */
+ public static final String GROUP_CHAT_CONTENT_TYPE =
+ "vnd.android.cursor.dir/im-groupMessages";
+
+ /**
+ * The MIME type of a {@link #CONTENT_URI} subdirectory of a single groupchat message.
+ */
+ public static final String GROUP_CHAT_CONTENT_ITEM_TYPE =
+ "vnd.android.cursor.item/im-groupMessages";
+ /**
* The MIME type of {@link #CONTENT_URI} providing a directory of
* people.
*/
@@ -992,6 +1057,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 +1189,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 {