blob: a62210fe4d16360385eaf82359122640d7d775d8 [file] [log] [blame]
Nick Pelly9439a7f2009-06-30 12:04:36 -07001/*
2 * Copyright (c) 2008-2009, Motorola, Inc.
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * - Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * - Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 *
16 * - Neither the name of the Motorola, Inc. nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33package javax.obex;
34
Nick Pelly2e0da962009-06-30 16:28:54 -070035/**
36 * @hide
37 */
38public final class ApplicationParameter {
Nick Pelly9439a7f2009-06-30 12:04:36 -070039
Tao Liejun3998bf02009-07-02 19:29:09 +080040 private byte[] mArray;
41
42 private int mLength;
43
44 private int mMaxLength = 1000;
Nick Pelly9439a7f2009-06-30 12:04:36 -070045
46 public static class TRIPLET_TAGID {
47 public static final byte ORDER_TAGID = 0x01;
48
49 public static final byte SEARCH_VALUE_TAGID = 0x02;
50
51 public static final byte SEARCH_ATTRIBUTE_TAGID = 0x03;
52
Nick Pelly2e0da962009-06-30 16:28:54 -070053 // if equals to "0", PSE only reply number of contacts
54 public static final byte MAXLISTCOUNT_TAGID = 0x04;
Nick Pelly9439a7f2009-06-30 12:04:36 -070055
56 public static final byte LISTSTARTOFFSET_TAGID = 0x05;
57
58 public static final byte FILTER_TAGID = 0x06;
59
60 public static final byte FORMAT_TAGID = 0x07;
61
Nick Pelly2e0da962009-06-30 16:28:54 -070062 // only used if max list count = 0
63 public static final byte PHONEBOOKSIZE_TAGID = 0x08;
Nick Pelly9439a7f2009-06-30 12:04:36 -070064
Nick Pelly2e0da962009-06-30 16:28:54 -070065 // only used in "mch" in response
66 public static final byte NEWMISSEDCALLS_TAGID = 0x09;
Nick Pelly9439a7f2009-06-30 12:04:36 -070067 }
68
69 public static class TRIPLET_VALUE {
70 public static class ORDER {
71 public static final byte ORDER_BY_INDEX = 0x00;
72
73 public static final byte ORDER_BY_ALPHANUMERIC = 0x01;
74
75 public static final byte ORDER_BY_PHONETIC = 0x02;
76 }
77
78 public static class SEARCHATTRIBUTE {
79 public static final byte SEARCH_BY_NAME = 0x00;
80
81 public static final byte SEARCH_BY_NUMBER = 0x01;
82
83 public static final byte SEARCH_BY_SOUND = 0x02;
84 }
85
86 public static class FORMAT {
87 public static final byte VCARD_VERSION_21 = 0x00;
88
89 public static final byte VCARD_VERSION_30 = 0x01;
90 }
91 }
92
93 public static class TRIPLET_LENGTH {
94 public static final byte ORDER_LENGTH = 1;
95
Nick Pelly9439a7f2009-06-30 12:04:36 -070096 public static final byte SEARCH_ATTRIBUTE_LENGTH = 1;
97
98 public static final byte MAXLISTCOUNT_LENGTH = 2;
99
100 public static final byte LISTSTARTOFFSET_LENGTH = 2;
101
102 public static final byte FILTER_LENGTH = 8;
103
104 public static final byte FORMAT_LENGTH = 1;
105
106 public static final byte PHONEBOOKSIZE_LENGTH = 2;
107
108 public static final byte NEWMISSEDCALLS_LENGTH = 1;
109 }
110
Nick Pelly9439a7f2009-06-30 12:04:36 -0700111 public ApplicationParameter() {
Tao Liejun3998bf02009-07-02 19:29:09 +0800112 mArray = new byte[mMaxLength];
113 mLength = 0;
Nick Pelly9439a7f2009-06-30 12:04:36 -0700114 }
115
116 public void addAPPHeader(byte tag, byte len, byte[] value) {
Tao Liejun3998bf02009-07-02 19:29:09 +0800117 if ((mLength + len + 2) > mMaxLength) {
118 byte[] array_tmp = new byte[mLength + 4 * len];
119 System.arraycopy(mArray, 0, array_tmp, 0, mLength);
120 mArray = array_tmp;
121 mMaxLength = mLength + 4 * len;
Nick Pelly9439a7f2009-06-30 12:04:36 -0700122 }
Tao Liejun3998bf02009-07-02 19:29:09 +0800123 mArray[mLength++] = tag;
124 mArray[mLength++] = len;
125 System.arraycopy(value, 0, mArray, mLength, len);
126 mLength += len;
Nick Pelly9439a7f2009-06-30 12:04:36 -0700127 }
128
129 public byte[] getAPPparam() {
Tao Liejun3998bf02009-07-02 19:29:09 +0800130 byte[] para = new byte[mLength];
131 System.arraycopy(mArray, 0, para, 0, mLength);
Nick Pelly9439a7f2009-06-30 12:04:36 -0700132 return para;
133 }
134}