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
17package com.android.providers.contacts;
18
19import android.content.ContentValues;
20import android.database.Cursor;
21import android.net.Uri;
22import android.os.ParcelFileDescriptor;
23import android.util.ArraySet;
24
25import com.android.providers.contacts.VoicemailContentProvider.UriData;
26
27import java.io.FileNotFoundException;
28
29/**
30 * Defines interfaces for communication between voicemail content provider and voicemail table
31 * implementations.
32 */
33public 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 {
39        public Uri insert(UriData uriData, ContentValues values);
40        public int delete(UriData uriData, String selection, String[] selectionArgs);
41        public Cursor query(UriData uriData, String[] projection, String selection,
42                String[] selectionArgs, String sortOrder);
43        public int update(UriData uriData, ContentValues values, String selection,
44                String[] selectionArgs);
45        public String getType(UriData uriData);
46        public ParcelFileDescriptor openFile(UriData uriData, String mode)
47                throws FileNotFoundException;
48        public ArraySet<String> getSourcePackages();
49    }
50
51    /**
52     * A helper interface that an implementation of {@link Delegate} uses to access common
53     * functionality across different voicemail tables.
54     */
55    public interface DelegateHelper {
56        /**
57         * Inserts source_package field into ContentValues. Used in insert operations.
58         */
59        public void checkAndAddSourcePackageIntoValues(UriData uriData, ContentValues values);
60
61        /**
62         * Opens the file pointed to by the column "_data".
63         * @throws FileNotFoundException
64         */
65        public ParcelFileDescriptor openDataFile(UriData uriData, String mode)
66                throws FileNotFoundException;
67    }
68}
69