|
1 /** |
|
2 BEEM is a videoconference application on the Android Platform. |
|
3 |
|
4 Copyright (C) 2009 by Frederic-Charles Barthelery, |
|
5 Jean-Manuel Da Silva, |
|
6 Nikita Kozlov, |
|
7 Philippe Lago, |
|
8 Jean Baptiste Vergely, |
|
9 Vincent Véronis. |
|
10 |
|
11 This file is part of BEEM. |
|
12 |
|
13 BEEM is free software: you can redistribute it and/or modify |
|
14 it under the terms of the GNU General Public License as published by |
|
15 the Free Software Foundation, either version 3 of the License, or |
|
16 (at your option) any later version. |
|
17 |
|
18 BEEM is distributed in the hope that it will be useful, |
|
19 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 GNU General Public License for more details. |
|
22 |
|
23 You should have received a copy of the GNU General Public License |
|
24 along with BEEM. If not, see <http://www.gnu.org/licenses/>. |
|
25 |
|
26 Please send bug reports with examples or suggestions to |
|
27 contact@beem-project.com or http://dev.beem-project.com/ |
|
28 |
|
29 Epitech, hereby disclaims all copyright interest in the program “Beem” |
|
30 written by Frederic-Charles Barthelery, |
|
31 Jean-Manuel Da Silva, |
|
32 Nikita Kozlov, |
|
33 Philippe Lago, |
|
34 Jean Baptiste Vergely, |
|
35 Vincent Veronis. |
|
36 |
|
37 Nicolas Sadirac, November 26, 2009 |
|
38 President of Epitech. |
|
39 |
|
40 Flavien Astraud, November 26, 2009 |
|
41 Head of the EIP Laboratory. |
|
42 |
|
43 */ |
1 package com.beem.project.beem.provider; |
44 package com.beem.project.beem.provider; |
2 |
45 |
3 import java.util.HashMap; |
46 import java.util.HashMap; |
4 |
47 |
5 import android.content.ContentProvider; |
48 import android.content.ContentProvider; |
12 import android.database.sqlite.SQLiteQueryBuilder; |
55 import android.database.sqlite.SQLiteQueryBuilder; |
13 import android.net.Uri; |
56 import android.net.Uri; |
14 import android.provider.BaseColumns; |
57 import android.provider.BaseColumns; |
15 import android.text.TextUtils; |
58 import android.text.TextUtils; |
16 |
59 |
|
60 // TODO: Auto-generated Javadoc |
17 /** |
61 /** |
18 * UserProvider class. |
62 * UserProvider class. |
19 * @author Jamu |
63 * @author Jamu |
20 */ |
64 */ |
21 public class UserProvider extends ContentProvider { |
65 public class UserProvider extends ContentProvider { |
40 sUsersProjectionMap.put(Beem.Users.DATE_MODIFIED, Beem.Users.DATE_MODIFIED); |
84 sUsersProjectionMap.put(Beem.Users.DATE_MODIFIED, Beem.Users.DATE_MODIFIED); |
41 } |
85 } |
42 |
86 |
43 private BeemDatabaseHelper mOpenHelper; |
87 private BeemDatabaseHelper mOpenHelper; |
44 |
88 |
|
89 /* (non-Javadoc) |
|
90 * @see android.content.ContentProvider#delete(android.net.Uri, java.lang.String, java.lang.String[]) |
|
91 */ |
45 @Override |
92 @Override |
46 public int delete(Uri uri, String selection, String[] selectionArgs) { |
93 public int delete(Uri uri, String selection, String[] selectionArgs) { |
47 SQLiteDatabase db = mOpenHelper.getWritableDatabase(); |
94 SQLiteDatabase db = mOpenHelper.getWritableDatabase(); |
48 int count; |
95 int count; |
49 |
96 |
64 |
111 |
65 getContext().getContentResolver().notifyChange(uri, null); |
112 getContext().getContentResolver().notifyChange(uri, null); |
66 return count; |
113 return count; |
67 } |
114 } |
68 |
115 |
|
116 /* (non-Javadoc) |
|
117 * @see android.content.ContentProvider#getType(android.net.Uri) |
|
118 */ |
69 @Override |
119 @Override |
70 public String getType(Uri uri) { |
120 public String getType(Uri uri) { |
71 switch (S_URI_MATCHER.match(uri)) { |
121 switch (S_URI_MATCHER.match(uri)) { |
72 case USERS: |
122 case USERS: |
73 return Beem.Users.CONTENT_TYPE; |
123 return Beem.Users.CONTENT_TYPE; |
78 default: |
128 default: |
79 throw new IllegalArgumentException("Unknown URI " + uri); |
129 throw new IllegalArgumentException("Unknown URI " + uri); |
80 } |
130 } |
81 } |
131 } |
82 |
132 |
|
133 /* (non-Javadoc) |
|
134 * @see android.content.ContentProvider#insert(android.net.Uri, android.content.ContentValues) |
|
135 */ |
83 @Override |
136 @Override |
84 public Uri insert(Uri uri, ContentValues initialValues) { |
137 public Uri insert(Uri uri, ContentValues initialValues) { |
85 // Validate the requested uri |
138 // Validate the requested uri |
86 if (S_URI_MATCHER.match(uri) != USERS) { |
139 if (S_URI_MATCHER.match(uri) != USERS) { |
87 throw new IllegalArgumentException("Unknown URI " + uri); |
140 throw new IllegalArgumentException("Unknown URI " + uri); |
118 } |
171 } |
119 |
172 |
120 throw new SQLException("Failed to insert row into " + uri); |
173 throw new SQLException("Failed to insert row into " + uri); |
121 } |
174 } |
122 |
175 |
|
176 /* (non-Javadoc) |
|
177 * @see android.content.ContentProvider#onCreate() |
|
178 */ |
123 @Override |
179 @Override |
124 public boolean onCreate() { |
180 public boolean onCreate() { |
125 mOpenHelper = new BeemDatabaseHelper(getContext(), TAG, Beem.USERS_TABLE_NAME, Beem.Users.QUERY_CREATE); |
181 mOpenHelper = new BeemDatabaseHelper(getContext(), TAG, Beem.USERS_TABLE_NAME, Beem.Users.QUERY_CREATE); |
126 return true; |
182 return true; |
127 } |
183 } |
128 |
184 |
|
185 /* (non-Javadoc) |
|
186 * @see android.content.ContentProvider#query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String) |
|
187 */ |
129 @Override |
188 @Override |
130 public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { |
189 public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { |
131 SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); |
190 SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); |
132 |
191 |
133 switch (S_URI_MATCHER.match(uri)) { |
192 switch (S_URI_MATCHER.match(uri)) { |
162 // changes |
221 // changes |
163 c.setNotificationUri(getContext().getContentResolver(), uri); |
222 c.setNotificationUri(getContext().getContentResolver(), uri); |
164 return c; |
223 return c; |
165 } |
224 } |
166 |
225 |
|
226 /* (non-Javadoc) |
|
227 * @see android.content.ContentProvider#update(android.net.Uri, android.content.ContentValues, java.lang.String, java.lang.String[]) |
|
228 */ |
167 @Override |
229 @Override |
168 public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { |
230 public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { |
169 SQLiteDatabase db = mOpenHelper.getWritableDatabase(); |
231 SQLiteDatabase db = mOpenHelper.getWritableDatabase(); |
170 int count; |
232 int count; |
171 |
233 |