1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package com.android.providers.contacts; 18 19 import android.content.ContentValues; 20 import android.database.Cursor; 21 import android.net.Uri; 22 import android.os.ParcelFileDescriptor; 23 import android.util.ArraySet; 24 25 import com.android.providers.contacts.VoicemailContentProvider.UriData; 26 27 import java.io.FileNotFoundException; 28 29 /** 30 * Defines interfaces for communication between voicemail content provider and voicemail table 31 * implementations. 32 */ 33 public interface VoicemailTable { 34 /** 35 * Interface that the voicemail content provider uses to delegate database level operations 36 * to the appropriate voicemail table implementation. 37 */ 38 public interface Delegate { insert(UriData uriData, ContentValues values)39 public Uri insert(UriData uriData, ContentValues values); delete(UriData uriData, String selection, String[] selectionArgs)40 public int delete(UriData uriData, String selection, String[] selectionArgs); query(UriData uriData, String[] projection, String selection, String[] selectionArgs, String sortOrder)41 public Cursor query(UriData uriData, String[] projection, String selection, 42 String[] selectionArgs, String sortOrder); update(UriData uriData, ContentValues values, String selection, String[] selectionArgs)43 public int update(UriData uriData, ContentValues values, String selection, 44 String[] selectionArgs); getType(UriData uriData)45 public String getType(UriData uriData); openFile(UriData uriData, String mode)46 public ParcelFileDescriptor openFile(UriData uriData, String mode) 47 throws FileNotFoundException; getSourcePackages()48 public ArraySet<String> getSourcePackages(); 49 bulkInsert(UriData uriData, ContentValues[] values)50 int bulkInsert(UriData uriData, ContentValues[] values); 51 } 52 53 /** 54 * A helper interface that an implementation of {@link Delegate} uses to access common 55 * functionality across different voicemail tables. 56 */ 57 public interface DelegateHelper { 58 /** 59 * Inserts source_package field into ContentValues. Used in insert operations. 60 */ checkAndAddSourcePackageIntoValues(UriData uriData, ContentValues values)61 public void checkAndAddSourcePackageIntoValues(UriData uriData, ContentValues values); 62 63 /** 64 * Opens the file pointed to by the column "_data". 65 * @throws FileNotFoundException 66 */ openDataFile(UriData uriData, String mode)67 public ParcelFileDescriptor openDataFile(UriData uriData, String mode) 68 throws FileNotFoundException; 69 } 70 } 71