1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.marre.sms.nokia;
24
25 import java.io.UnsupportedEncodingException;
26
27 /***
28 * Nokia Picture message
29 * <p>
30 * @author Markus Eriksson
31 * @version $Id: NokiaPictureMessage.java,v 1.8 2002/10/09 19:30:32 c95men Exp $
32 */
33 public class NokiaPictureMessage extends NokiaMultipartMessage
34 {
35 /***
36 * Creates a Nokia Picture Message
37 *
38 * @param theBitmap
39 * @param theMsg
40 */
41 public NokiaPictureMessage(OtaBitmap theBitmap, String theMsg)
42 {
43 this(theBitmap, theMsg, false);
44 }
45
46 /***
47 * Creates a Nokia Picture Message
48 *
49 * @param theBitmap
50 * @param theMsg
51 */
52 public NokiaPictureMessage(byte[] theBitmap, String theMsg)
53 {
54 this(theBitmap, theMsg, false);
55 }
56
57 /***
58 * Creates a Nokia Picture Message
59 *
60 * @param theBitmap
61 * @param theMsg
62 * @param asUnicode Set to true if text should be sent as unicode
63 */
64 public NokiaPictureMessage(OtaBitmap theBitmap, String theMsg, boolean asUnicode)
65 {
66 this(theBitmap.getBytes(), theMsg, asUnicode);
67 }
68
69 /***
70 * Creates a Nokia Picture Message
71 *
72 * @param theBitmap
73 * @param theMsg
74 * @param asUnicode Set to true if text should be sent as unicode
75 */
76 public NokiaPictureMessage(byte[] theBitmap, String theMsg, boolean asUnicode)
77 {
78 addBitmap(theBitmap);
79 addText(theMsg, asUnicode);
80 }
81
82 /***
83 * Used internally to add the image
84 *
85 * @param theBitmap
86 */
87 private void addBitmap(byte[] theBitmap)
88 {
89 addMultipart(NokiaPart.ITEM_OTA_BITMAP, theBitmap);
90 }
91
92 /***
93 * Used internally to add the image
94 * @param theBitmap
95 */
96 private void addBitmap(OtaBitmap theBitmap)
97 {
98 addMultipart(NokiaPart.ITEM_OTA_BITMAP, theBitmap.getBytes());
99 }
100
101 /***
102 * Used internally to add text
103 *
104 * @param theMsg
105 * @param asUnicode
106 */
107 private void addText(String theMsg, boolean asUnicode)
108 {
109 try
110 {
111 if (asUnicode)
112 {
113 addMultipart(NokiaPart.ITEM_TEXT_UNICODE, theMsg.getBytes("UTF-16BE"));
114 }
115 else
116 {
117 addMultipart(NokiaPart.ITEM_TEXT_ISO_8859_1, theMsg.getBytes("ISO-8859-1"));
118 }
119 }
120 catch (UnsupportedEncodingException ex)
121 {
122
123 }
124 }
125 }
126