# HG changeset patch # User Nikita Kozlov # Date 1268507067 -3600 # Node ID 915b3dde98515a91481585996b775191a90f59bc # Parent 8ca359035c84e02a3b8c819680921320a777142e adding notification preference for invite notifications some checkstyles removing of unused provider package diff -r 8ca359035c84 -r 915b3dde9851 src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Sat Mar 13 19:32:31 2010 +0100 +++ b/src/com/beem/project/beem/BeemService.java Sat Mar 13 20:04:27 2010 +0100 @@ -434,7 +434,8 @@ if (intentAction.equals(Intent.ACTION_SCREEN_OFF)) { mOldMode = mConnection.getPreviousMode(); mOldStatus = mConnection.getPreviousStatus(); - mConnection.changeStatus(Status.CONTACT_STATUS_AWAY, mSettings.getString("settings_away_message", "Away")); + mConnection.changeStatus(Status.CONTACT_STATUS_AWAY, + mSettings.getString("settings_away_message", "Away")); } else if (intentAction.equals(Intent.ACTION_SCREEN_ON)) { mConnection.changeStatus(mOldMode, mOldStatus); } diff -r 8ca359035c84 -r 915b3dde9851 src/com/beem/project/beem/provider/Beem.java --- a/src/com/beem/project/beem/provider/Beem.java Sat Mar 13 19:32:31 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,204 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.provider; - -import android.net.Uri; -import android.provider.BaseColumns; - -// TODO: Auto-generated Javadoc -/** - * Convenience definitions for BEEM's providers. - */ -public final class Beem { - - /** - * Contacts table. - */ - public static final class Contacts implements BaseColumns { - - /** The query used to create the table. */ - public static final String QUERY_CREATE = "CREATE TABLE " + Beem.CONTACTS_TABLE_NAME + " (" + BaseColumns._ID - + " INTEGER PRIMARY KEY AUTOINCREMENT," + Contacts.UID + " INTEGER, " + Contacts.JID + " INTEGER," - + Contacts.NICKNAME + " TEXT," + Contacts.ALIAS + " TEXT," + Contacts.DATE_CREATED + " INTEGER," - + Contacts.DATE_MODIFIED + " INTEGER" + ");"; - - /** The content:// style URL for Contacts table. */ - public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/contacts"); - - /** The MIME type of {@link #CONTENT_URI} providing a directory of contacts. */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.beem.project.contact"; - - /** The MIME type of a {@link #CONTENT_URI} sub-directory of a single contact. */ - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.beem.project.contact"; - - /** The default sort order for this table. */ - public static final String DEFAULT_SORT_ORDER = "nickname ASC"; - - /** - * The user id having the contact - *

- * Type: INTEGER - *

- * . - */ - public static final String UID = "uid"; - - /** - * The JabberID of the contact - *

- * Type: INTEGER - *

- * . - */ - public static final String JID = "jid"; - - /** - * The nickname of the contact - *

- * Type: TEXT - *

- * . - */ - public static final String NICKNAME = "nickname"; - - /** - * The alias of the contact - *

- * Type: TEXT - *

- * . - */ - public static final String ALIAS = "alias"; - - /** - * The timestamp for when the contact was created - *

- * Type: INTEGER (long from System.curentTimeMillis()) - *

- * . - */ - public static final String DATE_CREATED = "created"; - - /** - * The timestamp for when the contact was last modified - *

- * Type: INTEGER (long from System.curentTimeMillis()) - *

- * . - */ - public static final String DATE_MODIFIED = "modified"; - - } - - /** - * Users table. - */ - public static final class Users implements BaseColumns { - - /** The query used to create the table. */ - public static final String QUERY_CREATE = "CREATE TABLE " + Beem.USERS_TABLE_NAME + " (" + BaseColumns._ID - + " INTEGER PRIMARY KEY AUTOINCREMENT," + Users.JUSERNAME + " TEXT," + Users.DATE_CREATED + " INTEGER," - + Users.DATE_MODIFIED + " INTEGER" + ");"; - - /** The content:// style URL for Contacts table. */ - public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/users"); - - /** The MIME type of {@link #CONTENT_URI} providing a directory of users. */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.beem.project.user"; - - /** The MIME type of a {@link #CONTENT_URI} sub-directory of a single user. */ - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.beem.project.user"; - - /** The default sort order for this table. */ - public static final String DEFAULT_SORT_ORDER = "_id ASC"; - - /** - * The Jabber username of the user - *

- * Type: TEXT - *

- * . - */ - public static final String JUSERNAME = "username"; - - /** - * The timestamp for when the user was created - *

- * Type: INTEGER (long from System.curentTimeMillis()) - *

- * . - */ - public static final String DATE_CREATED = "created"; - - /** - * The timestamp for when the user was last modified - *

- * Type: INTEGER (long from System.curentTimeMillis()) - *

- * . - */ - public static final String DATE_MODIFIED = "modified"; - } - - /** AUTHORITY. */ - public static final String AUTHORITY = "com.beem.project.provider"; - - /** DB Name. */ - public static final String DB_NAME = "beem.db"; - - /** DB Version. */ - public static final int DB_VERSION = 2; - - /** Name of the users table. */ - public static final String USERS_TABLE_NAME = "users"; - - /** Name of the contacts table. */ - public static final String CONTACTS_TABLE_NAME = "contacts"; - - /** - * Constructor. - */ - private Beem() { - } -} diff -r 8ca359035c84 -r 915b3dde9851 src/com/beem/project/beem/provider/BeemDatabaseHelper.java --- a/src/com/beem/project/beem/provider/BeemDatabaseHelper.java Sat Mar 13 19:32:31 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,96 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.provider; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; -import android.util.Log; - -// TODO: Auto-generated Javadoc -/** - * BeemDatabaseHelper class. - * @author Jamu - */ -public class BeemDatabaseHelper extends SQLiteOpenHelper { - - private final String mTag; - private final String mTableName; - private final String mCreationQuery; - - /** - * BeemDatabaseHelper class. - * @param context the context. - * @param tag the tag. - * @param tableName the tableName. - * @param creationQuery the creation query. - */ - public BeemDatabaseHelper(final Context context, final String tag, final String tableName, - final String creationQuery) { - super(context, Beem.DB_NAME, null, Beem.DB_VERSION); - - this.mTag = tag; - this.mTableName = tableName; - this.mCreationQuery = creationQuery; - } - - /* (non-Javadoc) - * @see android.database.sqlite.SQLiteOpenHelper#onCreate(android.database.sqlite.SQLiteDatabase) - */ - @Override - public void onCreate(SQLiteDatabase db) { - db.execSQL(this.mCreationQuery); - } - - /* (non-Javadoc) - * @see android.database.sqlite.SQLiteOpenHelper#onUpgrade(android.database.sqlite.SQLiteDatabase, int, int) - */ - @Override - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - Log.w(this.mTag, "Upgrading database from version " + oldVersion + " to " + newVersion - + ", which will destroy all old data"); - db.execSQL("DROP TABLE IF EXISTS " + this.mTableName + ";"); - onCreate(db); - } -} diff -r 8ca359035c84 -r 915b3dde9851 src/com/beem/project/beem/provider/ContactProvider.java --- a/src/com/beem/project/beem/provider/ContactProvider.java Sat Mar 13 19:32:31 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,268 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.provider; - -import java.util.HashMap; - -import android.content.ContentProvider; -import android.content.ContentUris; -import android.content.ContentValues; -import android.content.UriMatcher; -import android.database.Cursor; -import android.database.SQLException; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteQueryBuilder; -import android.net.Uri; -import android.provider.BaseColumns; -import android.text.TextUtils; - -// TODO: Auto-generated Javadoc -/** - * ContactProvider class. - * @author dasilvj - */ -public class ContactProvider extends ContentProvider { - - private static final String TAG = "ContactProvider"; - - private static HashMap sContactsProjectionMap; - - private static final int CONTACTS = 1; - private static final int CONTACT_ID = 2; - - private static final UriMatcher S_URI_MATCHER; - static { - S_URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH); - S_URI_MATCHER.addURI(Beem.AUTHORITY, "contacts", CONTACTS); - S_URI_MATCHER.addURI(Beem.AUTHORITY, "contacts/#", CONTACT_ID); - - sContactsProjectionMap = new HashMap(); - sContactsProjectionMap.put(BaseColumns._ID, BaseColumns._ID); - sContactsProjectionMap.put(Beem.Contacts.UID, Beem.Contacts.UID); - sContactsProjectionMap.put(Beem.Contacts.JID, Beem.Contacts.JID); - sContactsProjectionMap.put(Beem.Contacts.NICKNAME, Beem.Contacts.NICKNAME); - sContactsProjectionMap.put(Beem.Contacts.ALIAS, Beem.Contacts.ALIAS); - sContactsProjectionMap.put(Beem.Contacts.DATE_CREATED, Beem.Contacts.DATE_CREATED); - sContactsProjectionMap.put(Beem.Contacts.DATE_MODIFIED, Beem.Contacts.DATE_MODIFIED); - } - - private BeemDatabaseHelper mOpenHelper; - - /* (non-Javadoc) - * @see android.content.ContentProvider#delete(android.net.Uri, java.lang.String, java.lang.String[]) - */ - @Override - public int delete(Uri uri, String selection, String[] selectionArgs) { - SQLiteDatabase db = mOpenHelper.getWritableDatabase(); - int count; - - switch (S_URI_MATCHER.match(uri)) { - case CONTACTS: - count = db.delete(Beem.CONTACTS_TABLE_NAME, selection, selectionArgs); - break; - - case CONTACT_ID: - String contactId = uri.getPathSegments().get(1); - count = db.delete(Beem.CONTACTS_TABLE_NAME, BaseColumns._ID + "=" + contactId - + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs); - break; - - default: - throw new IllegalArgumentException("Unknown URI " + uri); - } - - getContext().getContentResolver().notifyChange(uri, null); - return count; - } - - /* (non-Javadoc) - * @see android.content.ContentProvider#getType(android.net.Uri) - */ - @Override - public String getType(Uri uri) { - switch (S_URI_MATCHER.match(uri)) { - case CONTACTS: - return Beem.Contacts.CONTENT_TYPE; - - case CONTACT_ID: - return Beem.Contacts.CONTENT_ITEM_TYPE; - - default: - throw new IllegalArgumentException("Unknown URI " + uri); - } - } - - /* (non-Javadoc) - * @see android.content.ContentProvider#insert(android.net.Uri, android.content.ContentValues) - */ - @Override - public Uri insert(Uri uri, ContentValues initialValues) { - // Validate the requested uri - if (S_URI_MATCHER.match(uri) != CONTACTS) { - throw new IllegalArgumentException("Unknown URI " + uri); - } - - ContentValues values; - if (initialValues != null) { - values = new ContentValues(initialValues); - } else { - values = new ContentValues(); - } - - Long now = Long.valueOf(System.currentTimeMillis()); - - // Make sure that the fields are all set - if (!values.containsKey(Beem.Contacts.UID)) { - // TODO :: Must check that the UID exists using UserProvider - throw new SQLException("No UID specified. Failed to insert row into " + uri); - } - - if (!values.containsKey(Beem.Contacts.JID)) { - values.put(Beem.Contacts.JID, ""); - } - - if (!values.containsKey(Beem.Contacts.NICKNAME)) { - values.put(Beem.Contacts.JID, ""); - } - - if (!values.containsKey(Beem.Contacts.ALIAS)) { - values.put(Beem.Contacts.JID, ""); - } - - if (!values.containsKey(Beem.Contacts.DATE_CREATED)) { - values.put(Beem.Contacts.DATE_CREATED, now); - } - - if (!values.containsKey(Beem.Contacts.DATE_MODIFIED)) { - values.put(Beem.Contacts.DATE_MODIFIED, now); - } - - SQLiteDatabase db = mOpenHelper.getWritableDatabase(); - long rowId = db.insert(Beem.CONTACTS_TABLE_NAME, BaseColumns._ID, values); - if (rowId > 0) { - Uri contactUri = ContentUris.withAppendedId(Beem.Contacts.CONTENT_URI, rowId); - getContext().getContentResolver().notifyChange(contactUri, null); - return contactUri; - } - - throw new SQLException("Failed to insert row into " + uri); - } - - /* (non-Javadoc) - * @see android.content.ContentProvider#onCreate() - */ - @Override - public boolean onCreate() { - mOpenHelper = new BeemDatabaseHelper(getContext(), TAG, Beem.CONTACTS_TABLE_NAME, Beem.Contacts.QUERY_CREATE); - return true; - } - - /* (non-Javadoc) - * @see android.content.ContentProvider#query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String) - */ - @Override - public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { - SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); - - switch (S_URI_MATCHER.match(uri)) { - case CONTACTS: - qb.setTables(Beem.CONTACTS_TABLE_NAME); - qb.setProjectionMap(sContactsProjectionMap); - break; - - case CONTACT_ID: - qb.setTables(Beem.USERS_TABLE_NAME); - qb.setProjectionMap(sContactsProjectionMap); - qb.appendWhere(BaseColumns._ID + "=" + uri.getPathSegments().get(1)); - break; - - default: - throw new IllegalArgumentException("Unknown URI " + uri); - } - - // If no sort order is specified use the default - String orderBy; - if (TextUtils.isEmpty(sortOrder)) { - orderBy = Beem.Contacts.DEFAULT_SORT_ORDER; - } else { - orderBy = sortOrder; - } - - // Get the database and run the query - SQLiteDatabase db = mOpenHelper.getReadableDatabase(); - Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy); - - // Tell the cursor what uri to watch, so it knows when its source data - // changes - c.setNotificationUri(getContext().getContentResolver(), uri); - return c; - } - - /* (non-Javadoc) - * @see android.content.ContentProvider#update(android.net.Uri, android.content.ContentValues, java.lang.String, java.lang.String[]) - */ - @Override - public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { - SQLiteDatabase db = mOpenHelper.getWritableDatabase(); - int count; - - switch (S_URI_MATCHER.match(uri)) { - case CONTACTS: - count = db.update(Beem.CONTACTS_TABLE_NAME, values, selection, selectionArgs); - break; - - case CONTACT_ID: - String contactId = uri.getPathSegments().get(1); - count = db.update(Beem.CONTACTS_TABLE_NAME, values, BaseColumns._ID + "=" + contactId - + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs); - break; - - default: - throw new IllegalArgumentException("Unknown URI " + uri); - } - - getContext().getContentResolver().notifyChange(uri, null); - return count; - } -} diff -r 8ca359035c84 -r 915b3dde9851 src/com/beem/project/beem/provider/UserProvider.java --- a/src/com/beem/project/beem/provider/UserProvider.java Sat Mar 13 19:32:31 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,252 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.provider; - -import java.util.HashMap; - -import android.content.ContentProvider; -import android.content.ContentUris; -import android.content.ContentValues; -import android.content.UriMatcher; -import android.database.Cursor; -import android.database.SQLException; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteQueryBuilder; -import android.net.Uri; -import android.provider.BaseColumns; -import android.text.TextUtils; - -// TODO: Auto-generated Javadoc -/** - * UserProvider class. - * @author Jamu - */ -public class UserProvider extends ContentProvider { - - private static final String TAG = "UserProvider"; - - private static HashMap sUsersProjectionMap; - - private static final int USERS = 1; - private static final int USER_ID = 2; - - private static final UriMatcher S_URI_MATCHER; - static { - S_URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH); - S_URI_MATCHER.addURI(Beem.AUTHORITY, "users", USERS); - S_URI_MATCHER.addURI(Beem.AUTHORITY, "users/#", USER_ID); - - sUsersProjectionMap = new HashMap(); - sUsersProjectionMap.put(BaseColumns._ID, BaseColumns._ID); - sUsersProjectionMap.put(Beem.Users.JUSERNAME, Beem.Users.JUSERNAME); - sUsersProjectionMap.put(Beem.Users.DATE_CREATED, Beem.Users.DATE_CREATED); - sUsersProjectionMap.put(Beem.Users.DATE_MODIFIED, Beem.Users.DATE_MODIFIED); - } - - private BeemDatabaseHelper mOpenHelper; - - /* (non-Javadoc) - * @see android.content.ContentProvider#delete(android.net.Uri, java.lang.String, java.lang.String[]) - */ - @Override - public int delete(Uri uri, String selection, String[] selectionArgs) { - SQLiteDatabase db = mOpenHelper.getWritableDatabase(); - int count; - - switch (S_URI_MATCHER.match(uri)) { - case USERS: - count = db.delete(Beem.USERS_TABLE_NAME, selection, selectionArgs); - break; - - case USER_ID: - String userID = uri.getPathSegments().get(1); - count = db.delete(Beem.USERS_TABLE_NAME, BaseColumns._ID + "=" + userID - + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs); - break; - - default: - throw new IllegalArgumentException("Unknown URI " + uri); - } - - getContext().getContentResolver().notifyChange(uri, null); - return count; - } - - /* (non-Javadoc) - * @see android.content.ContentProvider#getType(android.net.Uri) - */ - @Override - public String getType(Uri uri) { - switch (S_URI_MATCHER.match(uri)) { - case USERS: - return Beem.Users.CONTENT_TYPE; - - case USER_ID: - return Beem.Users.CONTENT_ITEM_TYPE; - - default: - throw new IllegalArgumentException("Unknown URI " + uri); - } - } - - /* (non-Javadoc) - * @see android.content.ContentProvider#insert(android.net.Uri, android.content.ContentValues) - */ - @Override - public Uri insert(Uri uri, ContentValues initialValues) { - // Validate the requested uri - if (S_URI_MATCHER.match(uri) != USERS) { - throw new IllegalArgumentException("Unknown URI " + uri); - } - - ContentValues values; - if (initialValues != null) { - values = new ContentValues(initialValues); - } else { - values = new ContentValues(); - } - - Long now = Long.valueOf(System.currentTimeMillis()); - - // Make sure that the fields are all set - if (!values.containsKey(Beem.Users.JUSERNAME)) { - throw new SQLException("No JUSERNAME specified. Failed to insert row into " + uri); - } - - if (!values.containsKey(Beem.Users.DATE_CREATED)) { - values.put(Beem.Users.DATE_CREATED, now); - } - - if (!values.containsKey(Beem.Users.DATE_MODIFIED)) { - values.put(Beem.Users.DATE_MODIFIED, now); - } - - SQLiteDatabase db = mOpenHelper.getWritableDatabase(); - long rowId = db.insert(Beem.USERS_TABLE_NAME, BaseColumns._ID, values); - if (rowId > 0) { - Uri userUri = ContentUris.withAppendedId(Beem.Users.CONTENT_URI, rowId); - getContext().getContentResolver().notifyChange(userUri, null); - return userUri; - } - - throw new SQLException("Failed to insert row into " + uri); - } - - /* (non-Javadoc) - * @see android.content.ContentProvider#onCreate() - */ - @Override - public boolean onCreate() { - mOpenHelper = new BeemDatabaseHelper(getContext(), TAG, Beem.USERS_TABLE_NAME, Beem.Users.QUERY_CREATE); - return true; - } - - /* (non-Javadoc) - * @see android.content.ContentProvider#query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String) - */ - @Override - public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { - SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); - - switch (S_URI_MATCHER.match(uri)) { - case USERS: - qb.setTables(Beem.USERS_TABLE_NAME); - qb.setProjectionMap(sUsersProjectionMap); - break; - - case USER_ID: - qb.setTables(Beem.USERS_TABLE_NAME); - qb.setProjectionMap(sUsersProjectionMap); - qb.appendWhere(BaseColumns._ID + "=" + uri.getPathSegments().get(1)); - break; - - default: - throw new IllegalArgumentException("Unknown URI " + uri); - } - - // If no sort order is specified use the default - String orderBy; - if (TextUtils.isEmpty(sortOrder)) { - orderBy = Beem.Users.DEFAULT_SORT_ORDER; - } else { - orderBy = sortOrder; - } - - // Get the database and run the query - SQLiteDatabase db = mOpenHelper.getReadableDatabase(); - Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy); - - // Tell the cursor what uri to watch, so it knows when its source data - // changes - c.setNotificationUri(getContext().getContentResolver(), uri); - return c; - } - - /* (non-Javadoc) - * @see android.content.ContentProvider#update(android.net.Uri, android.content.ContentValues, java.lang.String, java.lang.String[]) - */ - @Override - public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { - SQLiteDatabase db = mOpenHelper.getWritableDatabase(); - int count; - - switch (S_URI_MATCHER.match(uri)) { - case USERS: - count = db.update(Beem.USERS_TABLE_NAME, values, selection, selectionArgs); - break; - - case USER_ID: - String userId = uri.getPathSegments().get(1); - count = db.update(Beem.USERS_TABLE_NAME, values, BaseColumns._ID + "=" + userId - + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs); - break; - - default: - throw new IllegalArgumentException("Unknown URI " + uri); - } - - getContext().getContentResolver().notifyChange(uri, null); - return count; - } -} diff -r 8ca359035c84 -r 915b3dde9851 src/com/beem/project/beem/provider/package-info.java --- a/src/com/beem/project/beem/provider/package-info.java Sat Mar 13 19:32:31 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ - -/** - * This package contains classes concerning hypothetical providers. - */ -package com.beem.project.beem.provider; - diff -r 8ca359035c84 -r 915b3dde9851 src/com/beem/project/beem/service/BeemChatManager.java --- a/src/com/beem/project/beem/service/BeemChatManager.java Sat Mar 13 19:32:31 2010 +0100 +++ b/src/com/beem/project/beem/service/BeemChatManager.java Sat Mar 13 20:04:27 2010 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. - */ +*/ package com.beem.project.beem.service; import java.util.ArrayList; @@ -76,110 +76,13 @@ * @author darisk */ public class BeemChatManager extends IChatManager.Stub { - - /** - * A listener for all the chat creation event that happens on the connection. - * @author darisk - */ - private class ChatListener extends IMessageListener.Stub implements ChatManagerListener { - - /** - * Constructor. - */ - public ChatListener() { - } - - /** - * {@inheritDoc} - */ - @Override - public void chatCreated(Chat chat, boolean locally) { - IChat newchat = getChat(chat); - Log.d(TAG, "Chat" + chat.toString() + " created locally " + locally + "with " + chat.getParticipant()); - try { - newchat.addMessageListener(mChatListener); - final int n = mRemoteChatCreationListeners.beginBroadcast(); - - for (int i = 0; i < n; i++) { - IChatManagerListener listener = mRemoteChatCreationListeners.getBroadcastItem(i); - listener.chatCreated(newchat, locally); - } - mRemoteChatCreationListeners.finishBroadcast(); - } catch (RemoteException e) { - // The RemoteCallbackList will take care of removing the - // dead listeners. - Log.w(TAG, " Error while triggering remote connection listeners in chat creation", e); - } - } - - /** - * Create the PendingIntent to launch our activity if the user select this chat notification. - * @param chat A ChatAdapter instance - * @return A Chat activity PendingIntent - */ - private PendingIntent makeChatIntent(IChat chat) { - Intent chatIntent = new Intent(mService, com.beem.project.beem.ui.Chat.class); - chatIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); - try { - chatIntent.setData(chat.getParticipant().toUri()); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } - PendingIntent contentIntent = PendingIntent.getActivity(mService, 0, chatIntent, - PendingIntent.FLAG_UPDATE_CURRENT); - return contentIntent; - } - - /** - * Set a notification of a new chat. - * @param chat The chat to access by the notification - */ - private void notifyNewChat(IChat chat) { - SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mService); - try { - CharSequence tickerText = mService.getBind().getRoster().getContact(chat.getParticipant().getJID()) - .getName(); - Notification notification = new Notification(android.R.drawable.stat_notify_chat, tickerText, System - .currentTimeMillis()); - if (!pref.getBoolean("settings_notification_disable_vibrate", true)) - notification.defaults -= Notification.DEFAULT_VIBRATE; - notification.flags = Notification.FLAG_AUTO_CANCEL; - notification.setLatestEventInfo(mService, tickerText, mService - .getString(R.string.BeemChatManagerNewMessage), makeChatIntent(chat)); - String ringtoneStr = pref.getString("settings_notification_snd", ""); - notification.sound = Uri.parse(ringtoneStr); - mService.sendNotification(chat.getParticipant().getJID().hashCode(), notification); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void processMessage(IChat chat, Message message) { - try { - if (!chat.isOpen() && message.getBody() != null) { - if (chat instanceof ChatAdapter) - mChats.put(chat.getParticipant().getJID(), (ChatAdapter) chat); - notifyNewChat(chat); - } - } catch (RemoteException e) { - Log.w(TAG, e.getMessage()); - } - } - - @Override - public void stateChanged(IChat chat) { } - } - /** Tag to use with log methods. */ public static final String TAG = "BeemChatManager"; private final ChatManager mAdaptee; private final Map mChats = new HashMap(); private final ChatListener mChatListener = new ChatListener(); - private final RemoteCallbackList mRemoteChatCreationListeners = new RemoteCallbackList(); + private final RemoteCallbackList mRemoteChatCreationListeners = + new RemoteCallbackList(); private final BeemService mService; /** @@ -312,4 +215,101 @@ mRemoteChatCreationListeners.unregister(listener); } + /** + * A listener for all the chat creation event that happens on the connection. + * @author darisk + */ + private class ChatListener extends IMessageListener.Stub implements ChatManagerListener { + + /** + * Constructor. + */ + public ChatListener() { + } + + /** + * {@inheritDoc} + */ + @Override + public void chatCreated(Chat chat, boolean locally) { + IChat newchat = getChat(chat); + Log.d(TAG, "Chat" + chat.toString() + " created locally " + locally + "with " + chat.getParticipant()); + try { + newchat.addMessageListener(mChatListener); + final int n = mRemoteChatCreationListeners.beginBroadcast(); + + for (int i = 0; i < n; i++) { + IChatManagerListener listener = mRemoteChatCreationListeners.getBroadcastItem(i); + listener.chatCreated(newchat, locally); + } + mRemoteChatCreationListeners.finishBroadcast(); + } catch (RemoteException e) { + // The RemoteCallbackList will take care of removing the + // dead listeners. + Log.w(TAG, " Error while triggering remote connection listeners in chat creation", e); + } + } + + /** + * Create the PendingIntent to launch our activity if the user select this chat notification. + * @param chat A ChatAdapter instance + * @return A Chat activity PendingIntent + */ + private PendingIntent makeChatIntent(IChat chat) { + Intent chatIntent = new Intent(mService, com.beem.project.beem.ui.Chat.class); + chatIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); + try { + chatIntent.setData(chat.getParticipant().toUri()); + } catch (RemoteException e) { + Log.e(TAG, e.getMessage()); + } + PendingIntent contentIntent = PendingIntent.getActivity(mService, 0, chatIntent, + PendingIntent.FLAG_UPDATE_CURRENT); + return contentIntent; + } + + /** + * Set a notification of a new chat. + * @param chat The chat to access by the notification + */ + private void notifyNewChat(IChat chat) { + SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mService); + try { + CharSequence tickerText = mService.getBind().getRoster().getContact(chat.getParticipant().getJID()) + .getName(); + Notification notification = new Notification(android.R.drawable.stat_notify_chat, tickerText, System + .currentTimeMillis()); + if (!pref.getBoolean("settings_notification_disable_vibrate", true)) + notification.defaults -= Notification.DEFAULT_VIBRATE; + notification.flags = Notification.FLAG_AUTO_CANCEL; + notification.setLatestEventInfo(mService, tickerText, mService + .getString(R.string.BeemChatManagerNewMessage), makeChatIntent(chat)); + String ringtoneStr = pref.getString("settings_notification_snd", ""); + notification.sound = Uri.parse(ringtoneStr); + mService.sendNotification(chat.getParticipant().getJID().hashCode(), notification); + } catch (RemoteException e) { + Log.e(TAG, e.getMessage()); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void processMessage(final IChat chat, Message message) { + try { + if (!chat.isOpen() && message.getBody() != null) { + if (chat instanceof ChatAdapter) { + mChats.put(chat.getParticipant().getJID(), (ChatAdapter) chat); + } + notifyNewChat(chat); + } + } catch (RemoteException e) { + Log.w(TAG, e.getMessage()); + } + } + + @Override + public void stateChanged(final IChat chat) { } + } } diff -r 8ca359035c84 -r 915b3dde9851 src/com/beem/project/beem/service/PrivacyListManagerAdapter.java --- a/src/com/beem/project/beem/service/PrivacyListManagerAdapter.java Sat Mar 13 19:32:31 2010 +0100 +++ b/src/com/beem/project/beem/service/PrivacyListManagerAdapter.java Sat Mar 13 20:04:27 2010 +0100 @@ -71,7 +71,8 @@ private final PrivacyListManager mPrivacyListManager; - private final RemoteCallbackList mPrivacyListListeners = new RemoteCallbackList(); + private final RemoteCallbackList mPrivacyListListeners = + new RemoteCallbackList(); private final PrivacyListListenerAdapter mPrivacyListListener = new PrivacyListListenerAdapter(); /** diff -r 8ca359035c84 -r 915b3dde9851 src/com/beem/project/beem/service/RosterAdapter.java --- a/src/com/beem/project/beem/service/RosterAdapter.java Sat Mar 13 19:32:31 2010 +0100 +++ b/src/com/beem/project/beem/service/RosterAdapter.java Sat Mar 13 20:04:27 2010 +0100 @@ -72,7 +72,8 @@ private static final String TAG = "RosterAdapter"; private final Roster mAdaptee; - private final RemoteCallbackList mRemoteRosListeners = new RemoteCallbackList(); + private final RemoteCallbackList mRemoteRosListeners = + new RemoteCallbackList(); private final Map mDefaultStatusMessages; private final RosterListenerAdapter mRosterListener = new RosterListenerAdapter(); diff -r 8ca359035c84 -r 915b3dde9851 src/com/beem/project/beem/service/XmppConnectionAdapter.java --- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sat Mar 13 19:32:31 2010 +0100 +++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sat Mar 13 20:04:27 2010 +0100 @@ -61,8 +61,10 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.net.Uri; import android.os.RemoteCallbackList; import android.os.RemoteException; +import android.preference.PreferenceManager; import android.util.Log; import com.beem.project.beem.BeemService; @@ -618,17 +620,21 @@ if (p.getType() != Presence.Type.subscribe) return; String from = p.getFrom(); - Notification notif = new Notification(android.R.drawable.stat_notify_more, mService.getString( + SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mService); + Notification notification = new Notification(android.R.drawable.stat_notify_more, mService.getString( R.string.AcceptContactRequest, from), System.currentTimeMillis()); - notif.defaults = Notification.DEFAULT_ALL; - notif.flags = Notification.FLAG_AUTO_CANCEL; + if (!pref.getBoolean("settings_notification_disable_vibrate", true)) + notification.defaults -= Notification.DEFAULT_VIBRATE; + notification.flags = Notification.FLAG_AUTO_CANCEL; Intent intent = new Intent(mService, Subscription.class); intent.putExtra("from", from); - notif.setLatestEventInfo(mService, from, mService + String ringtoneStr = pref.getString("settings_notification_snd", ""); + notification.sound = Uri.parse(ringtoneStr); + notification.setLatestEventInfo(mService, from, mService .getString(R.string.AcceptContactRequestFrom, from), PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT)); int id = p.hashCode(); - mService.sendNotification(id, notif); + mService.sendNotification(id, notification); } } diff -r 8ca359035c84 -r 915b3dde9851 tools/checkstyle.xml --- a/tools/checkstyle.xml Sat Mar 13 19:32:31 2010 +0100 +++ b/tools/checkstyle.xml Sat Mar 13 20:04:27 2010 +0100 @@ -202,7 +202,7 @@ - +