View Javadoc

1   /* ***** BEGIN LICENSE BLOCK *****
2    * Version: MPL 1.1
3    *
4    * The contents of this file are subject to the Mozilla Public License Version
5    * 1.1 (the "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    * http://www.mozilla.org/MPL/
8    *
9    * Software distributed under the License is distributed on an "AS IS" basis,
10   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11   * for the specific language governing rights and limitations under the
12   * License.
13   *
14   * The Original Code is "SMS Library for the Java platform".
15   *
16   * The Initial Developer of the Original Code is Markus Eriksson.
17   * Portions created by the Initial Developer are Copyright (C) 2002
18   * the Initial Developer. All Rights Reserved.
19   *
20   * Contributor(s):
21   *
22   * ***** END LICENSE BLOCK ***** */
23  package org.marre.sms.nokia;
24  
25  import java.io.UnsupportedEncodingException;
26  
27  import org.marre.sms.SmsUserData;
28  /***
29   * Nokia Downloadable Profile
30   *
31   * @author Markus Eriksson
32   * @version $Id: NokiaDownloadableProfile.java,v 1.6 2004/11/02 17:59:50 c95men Exp $
33   */
34  public class NokiaDownloadableProfile extends NokiaMultipartMessage
35  {
36      private String myProfileName;
37      private byte[] myScreenSaver;
38      private byte[] myRingingTone;
39  
40      public NokiaDownloadableProfile()
41      {
42      }
43  
44      public NokiaDownloadableProfile(String theProfileName)
45      {
46          setProfileName(theProfileName);
47      }
48  
49      public void setScreenSaver(byte[] theBitmap)
50      {
51          myScreenSaver = theBitmap;
52      }
53  
54      public void setScreenSaver(OtaBitmap theBitmap)
55      {
56          myScreenSaver = theBitmap.getBytes();
57      }
58  
59      public void setProfileName(String theProfileName)
60      {
61          myProfileName = theProfileName;
62      }
63  
64      public void setRingingTone(byte[] theRingingTone)
65      {
66          myRingingTone = theRingingTone;
67      }
68  
69      private void addProfileName(String theProfileName)
70      {
71      }
72  
73      public SmsUserData getUserData()
74      {
75          // Reset message
76          clear();
77  
78          // Create message
79          if (myProfileName != null)
80          {
81              try
82              {
83                  addMultipart(NokiaPart.ITEM_PROFILE_NAME, myProfileName.getBytes("UTF-16BE"));
84              }
85              catch (UnsupportedEncodingException ex)
86              {
87                  throw new RuntimeException(ex.getMessage());
88              }
89          }
90  
91          if (myScreenSaver != null)
92          {
93              addMultipart(NokiaPart.ITEM_SCREEN_SAVER, myScreenSaver);
94          }
95  
96          if (myRingingTone != null)
97          {
98              addMultipart(NokiaPart.ITEM_RINGTONE, myRingingTone);
99          }
100 
101         return super.getUserData();
102     }
103 }