001 package com.skype.api;
002
003 import java.io.IOException;
004 import java.util.*;
005 import com.skype.ipc.*;
006 /**
007 * Represents a local account. Encapsulates methods for Skype account creation, login and logout as well as account profile setting properties. NB! Unlike all the other SkypeKit classes, most of the Account class properties are actually read-write. In fact, there are two sorts of Account's read-write properties: server-side properties and local properties. Different setter methods need to be used for those two kinds. <br><br>The subset of server-side properties consists of all the policy properties (everything with _POLICY suffix) that are all of type int and can be set with SetServersideIntProperty method. There is currently only one server-side string property - OFFLINE_CALLFORWARD which can be set with SetServersideStrProperty setter. <br><br>The set of writeable account profile properties (local profile) is as follows; <br> - P_FULLNAME, <br> - P_BIRTHDAY, <br> - P_GENDER, <br> - P_LANGUAGES, <br> - P_COUNTRY, <br> - P_PROVINCE, <br> - P_CITY, <br> - P_PHONE_HOME, <br> - P_PHONE_OFFICE, <br> - P_PHONE_MOBILE, <br> - P_EMAILS, <br> - P_HOMEPAGE, <br> - P_ABOUT, <br> - P_MOOD_TEXT, <br> - P_TIMEZONE, <br> - P_AVATAR_IMAGE, <br> - P_RICH_MOOD_TEXT <br><br>These can be set with SetIntProperty, SetStrProperty and SetBinProperty setter methods. Note that there are special methods for changing account online status (availability) and enabling/disabling auto-login - SetAvailability and SetSavePwd. <br><br>Note that to set Account properties, you that Account needs to be logged in. Generally, assumption is that the first thing you do with an Account object after you retrieve it with Skype.GetAccount is login, with exception of creating a new account. <br><br>The Account class has no default constructor and creating an Account instance is not the same as creating a Skype account. To create a Skype account: <br><br> - obtain an Account instance by invoking Skype.GetAccount. This automatically sets P_SKYPENAME. <br> - set any additional profile-related properties. Skype recommends that you minimally set the following: <br> - their email address so that they can retrieve a lost password (P_EMAILS) <br> - the user's full name (P_FULLNAME) <br> - at least one phone number (P_PHONE_HOME, P_PHONE_HOME, P_PHONE_OFFICE) <br> - invoke Account.Register to actually create the account <br>
008 */
009
010
011 public class Account extends SkypeObject {
012
013
014 public interface AccountListener {
015 /** This event gets called when there are changes to Account properties defined in Account.PROPERTY */
016 public void OnPropertyChange(SkypeObject obj, PROPERTY prop, Object value);
017
018 }
019
020 public Account(int oid, Skype skype) {
021 super(oid,skype);
022 /**get default properties for this module **/
023 GetDefaultProps();
024 }
025
026 private static final int MODULE_ID = 5;
027
028 public static final int moduleID() {
029 return MODULE_ID;
030 }
031
032 /** Properties of the Account class */
033 public enum PROPERTY {
034
035 /** Account.STATUS, type: STATUS */
036 status(70),
037
038 /** Account.PWDCHANGESTATUS, type: PWDCHANGESTATUS */
039 pwdchangestatus(71),
040
041 /** This property should only be examined when Account.P_STATUS is LOGGED_OUT or LOGGED_OUT_AND_PWD_SAVED. That is, you should not monitor changes to this property in Account.OnChange callback, other than after already having checked that P_STATUS property has appropriate value. The reason for this is that the LOGOUTREASON does not get reset before the next login attempt. For example: if a user tried to log in with a wrong password, the LOGOUTREASON gets set to INCORRECT_PASSWORD. Now, if the user tries to log in again, and yet again submits an incorrect password, the value of the LOGOUTREASON does not change anymore, because it already is set to INCORRECT_PASSWORD. Consequently, Account.OnChange will not fire in this case. <br>, type: LOGOUTREASON */
042 logoutreason(73),
043
044 /** Account.COMMITSTATUS, type: COMMITSTATUS */
045 commitstatus(78),
046
047 /** suggested skypename. present if logoutreason==SKYPENAME_TAKEN, type: String */
048 suggested_skypename(72),
049
050 /** 'EUR', 'USD', etc., type: String */
051 skypeout_balance_currency(74),
052
053 /** balance in 'cents', type: int */
054 skypeout_balance(75),
055
056 /** decimal points in ACCOUNT_SKYPEOUT_BALANCE, type: int */
057 skypeout_precision(804),
058
059 /** space-separated list of skypein numbers, type: String */
060 skypein_numbers(76),
061
062 /** Account.CBLSYNCSTATUS, type: CBLSYNCSTATUS */
063 cblsyncstatus(79),
064
065 /** space-separated list of 'begSecond,endSecond,identity' tokens, type: String */
066 offline_callforward(77),
067
068 /** Server-side account property, use SetServerside*Property() to set, type: CHATPOLICY */
069 chat_policy(160),
070
071 /** Server-side account property, use SetServerside*Property() to set, type: SKYPECALLPOLICY */
072 skype_call_policy(161),
073
074 /** Server-side account property, use SetServerside*Property() to set, type: PSTNCALLPOLICY */
075 pstn_call_policy(162),
076
077 /** Server-side account property, use SetServerside*Property() to set, type: AVATARPOLICY */
078 avatar_policy(163),
079
080 /** Server-side account property, use SetServerside*Property() to set, type: BUDDYCOUNTPOLICY */
081 buddycount_policy(164),
082
083 /** Server-side account property, use SetServerside*Property() to set, type: TIMEZONEPOLICY */
084 timezone_policy(165),
085
086 /** Server-side account property, use SetServerside*Property() to set, type: WEBPRESENCEPOLICY */
087 webpresence_policy(166),
088
089 /** Server-side account property, use SetServerside*Property() to set, type: PHONENUMBERSPOLICY */
090 phonenumbers_policy(168),
091
092 /** Server-side account property, use SetServerside*Property() to set, type: VOICEMAILPOLICY */
093 voicemail_policy(169),
094
095 /** Alerts: opted out partner id's, space separated, type: String */
096 partner_optedout(773),
097
098 /** service information if the user is a paid service provider, type: String */
099 service_provider_info(800),
100
101 /** NB! Unlike your common UNIX timestamps, the registration_timestamp is special, as it counts MINUTES rather than seconds, from Epoch (January 1, 1970) <br>, type: int */
102 registration_timestamp(801),
103
104 /** number of times this user is logged in from other computers, type: int */
105 nr_of_other_instances(802),
106
107 /** type: String */
108 skypename(4),
109
110 /** type: String */
111 fullname(5),
112
113 /** YYYYMMDD, type: int */
114 birthday(7),
115
116 /** 1-male, 2-female, type: int */
117 gender(8),
118
119 /** ISO language codes, space-separated, type: String */
120 languages(9),
121
122 /** ISO country code, type: String */
123 country(10),
124
125 /** type: String */
126 province(11),
127
128 /** type: String */
129 city(12),
130
131 /** NB! string not integer, type: String */
132 phone_home(13),
133
134 /** type: String */
135 phone_office(14),
136
137 /** type: String */
138 phone_mobile(15),
139
140 /** This is a string property, that contains space-separated list of email addresses. When surfacing this property in your UI, you will need to take into account that there may be more than one email addresses in this property (i.e. split the value at spaces and display them as list). Similarly, when modifying this property with SetStrProperty method, your editor should allow editing of component email addresses separately and add them all up again, before submitting back to the account. <br>, type: String */
141 emails(16),
142
143 /** type: String */
144 homepage(17),
145
146 /** arbitrary introductory text, type: String */
147 about(18),
148
149 /** UNIX timestamp of last profile change, type: int */
150 profile_timestamp(19),
151
152 /** Personal mood text (visible to authorised users only). Max length 300 bytes. <br>, type: String */
153 mood_text(26),
154
155 /** 24*3600+diff_to_UTC_in_seconds. nb! changes with DST, type: int */
156 timezone(27),
157
158 /** Count of this user's authorized contacts. <br>, type: int */
159 nrof_authed_buddies(28),
160
161 /** Contact.AVAILABILITY, type: Contact.AVAILABILITY */
162 availability(34),
163
164 /** Account avatar picture can be set with Account.SetBinProperty method. The contact avatar picture is limited to max 96x96 pixels and 32000 bytes. If the submitted avatar picture exceeds either of these size limits, it is the responsibility of your client to scale the image down to appropriate size. <br><br>The avatar pictures have to be in JPG format. A SkypeKit client can enable the user to set the Account avatar in other picture formats, in which case the picture should be converted to JPG before submitting it. <br><br>In any case, the avatar picture should be pre-validated with the Skype.ValidateAvatar method. <br>, type: byte[] */
165 avatar_image(37),
166
167 /** UNIX timestamp of when current avatar was set, type: int */
168 avatar_timestamp(182),
169
170 /** UNIX timestamp of when current mood was set, type: int */
171 mood_timestamp(183),
172
173 /** XML version of CONTACT_MOOD_TEXT. Max length 1000 bytes. <br>, type: String */
174 rich_mood_text(205);
175
176 private static final Map<Integer,PROPERTY> lookup = new HashMap<Integer,PROPERTY>();
177
178 static {
179 for(PROPERTY s : EnumSet.allOf(PROPERTY.class))
180 lookup.put(s.getId(), s);
181 }
182
183 private final int id;
184
185 private PROPERTY(int value) {
186 this.id = value;
187 }
188
189 public int getId() { return id; }
190
191 public static PROPERTY get(int code) {
192 return lookup.get(code);
193 }
194
195 public static PROPERTY fromString(String s) {
196 for (PROPERTY p : lookup.values()) {
197 if (p.toString() == s) {
198 return p;
199 }
200 }
201 return null;
202 }
203 }
204
205 public Object GetPropertyAsEnum(int propid) {
206 return PROPERTY.get(propid);
207 }
208
209 public String GetStrProperty(PROPERTY prop) {
210 //check in propcache if so then return
211 if (mPropCache.containsKey(new Integer(prop.id))){
212 String value = (String)mPropCache.get(prop.id);
213 if (value != null && !(value.length() == 0) ){
214 return value;
215 }
216 }
217 //else get from skypekit...
218 GetPropertyRequest request = new GetPropertyRequest(5, mObjectId, prop.id);
219
220 String string = null;
221 GetPropertyResponse r = skype.GetProperty(request);
222 if (r != null){
223 string = r.GetAsString();
224 }
225
226 if (string != null)
227 {
228 mPropCache.put(new Integer(prop.id), string);
229 }
230 return string;
231 }
232
233 public int GetIntProperty(PROPERTY prop) {
234 //check in propcache if so then return
235 if (mPropCache.containsKey(new Integer(prop.id))){
236 int value = ((Integer)mPropCache.get(prop.id)).intValue();
237 if (value != 0){
238 return value;
239 }
240 }
241 //else get from skypekit...
242 GetPropertyRequest request = new GetPropertyRequest(moduleID(), mObjectId, prop.id);
243
244 Integer integer = null;
245 GetPropertyResponse r = skype.GetProperty(request);
246 if (r != null){
247 integer = r.GetAsInt();
248 }
249
250 if (integer != null)
251 {
252 mPropCache.put(new Integer(prop.id), integer);
253 return integer.intValue();
254 }
255 else
256 {
257 return 0;
258 }
259 }
260
261 public boolean GetBooleanProperty(PROPERTY prop) {
262 //check in propcache if so then return
263 if (mPropCache.containsKey(new Integer(prop.id))){
264 return ((Boolean)mPropCache.get(prop.id)).booleanValue();
265 }
266 //else get from skypekit...
267 GetPropertyRequest request = new GetPropertyRequest(moduleID(), mObjectId, prop.id);
268
269 Boolean boolResp = null;
270 GetPropertyResponse r = skype.GetProperty(request);
271 if (r != null){
272 boolResp = r.GetAsBoolean();
273 }
274
275 if (boolResp != null)
276 {
277 mPropCache.put(new Integer(prop.id), boolResp);
278 return boolResp.booleanValue();
279 }
280 else
281 {
282 return false;
283 }
284 }
285
286 public byte [] GetBinProperty(PROPERTY prop) {
287 //get from skypekit...
288 GetPropertyRequest request = new GetPropertyRequest(5, mObjectId, prop.id);
289
290 byte [] data = null;
291 GetPropertyResponse r = skype.GetProperty(request);
292 if (r != null) {
293 data = r.GetAsBinary();
294 }
295 return data;
296 }
297
298 /**default array of Account Properties that get fetched & cached upon class construction*/
299 private static PROPERTY [] defaultProperties = { PROPERTY.skypename, PROPERTY.fullname, PROPERTY.mood_text, PROPERTY.birthday, PROPERTY.skypeout_balance, PROPERTY.skypeout_balance_currency, PROPERTY.skypeout_precision, PROPERTY.availability, PROPERTY.cblsyncstatus};
300
301 private void GetDefaultProps() {
302 MultiGetPropertyRequest request = null;
303 ArrayList<Integer> proparray = null;
304 /**Add the single oid into array*/
305 ArrayList<Integer> oidarray=new ArrayList<Integer>();
306 oidarray.add(mObjectId);
307
308 /**Add all requested propids into array*/
309 proparray=new ArrayList<Integer>();
310 for (PROPERTY defaultProp : defaultProperties) {
311 proparray.add(defaultProp.getId());
312 }
313 /**Generate the request*/
314 request = new MultiGetPropertyRequest(moduleID(), oidarray,proparray);
315
316 /** Make Multi Get call*/
317 GetPropertyResponse r=skype.MultiGetProperty(request);
318 /**Verify that it is a proper multiresponse*/
319 if(!r.isMultiresponse())
320 {
321 return;
322 }
323 /**update property cache with results*/
324 mPropCache.putAll(r.GetAsMap(mObjectId, proparray));
325 }
326
327 /**
328 */
329 public enum STATUS {
330
331 /** */
332 LOGGED_OUT(1),
333
334 /** the account is logged out, but password is not needed for re-login*/
335 LOGGED_OUT_AND_PWD_SAVED(2),
336
337 /** connecting to P2P network*/
338 CONNECTING_TO_P2P(3),
339
340 /** connecting to login server*/
341 CONNECTING_TO_SERVER(4),
342
343 /** waiting for response from server*/
344 LOGGING_IN(5),
345
346 /** response OK. initialising account-specific lib structures*/
347 INITIALIZING(6),
348
349 /** alright, we're good to go!*/
350 LOGGED_IN(7),
351
352 /** Logout() has been called but not processed yet*/
353 LOGGING_OUT(8);
354
355 private static final Map<Integer,STATUS> lookup = new HashMap<Integer,STATUS>();
356
357 static {
358 for(STATUS s : EnumSet.allOf(STATUS.class))
359 lookup.put(s.getId(), s);
360 }
361
362 private final int id;
363
364 private STATUS(int value) {
365 this.id = value;
366 }
367
368 public int getId() { return id; }
369
370 public static STATUS get(int code) {
371 return lookup.get(code);
372 }
373
374 public static STATUS fromString(String s) {
375 for (STATUS p : lookup.values()) {
376 if (p.toString() == s) {
377 return p;
378 }
379 }
380 return null;
381 }
382 }
383
384 /**
385 * This is a legacy method. The progress argument does not return overall login progress. Instead, it used to return database mount or conversion progress in case of logging in with a newer client on an older database version. Currently, the progress value should always return 0 under normal circumstances. There is currently no functionality in the SkypeKit API to accurately guess how long the login will take, as the P2P connect times are unpredictable. The maximum progress granularity available through SkypeKit API is currently the Account.P_STATUS property values. <br>
386 * @return GetStatusWithProgressResult
387 */
388 public GetStatusWithProgressResult GetStatusWithProgress() {
389
390 Request request = null;
391 try {
392 request = new XCallRequest(5,1);
393 } catch (IOException e) {
394 e.printStackTrace();
395 if (skype.errorListener != null)
396 skype.errorListener.OnSkypeKitFatalError();
397 }
398 request.addParm('O',0,mObjectId);
399
400 Response r = skype.XCall((XCallRequest)request);
401
402 if (r.isErrCall())
403 return null;
404
405 GetStatusWithProgressResult result = new GetStatusWithProgressResult();
406
407 STATUS status = null;
408 status = STATUS.get(r.GetAsInt(1));
409 result.status = status;
410
411 int progress = 0;
412 progress = r.GetAsInt(2);
413 result.progress = progress;
414
415 return result;
416 }
417
418 public class GetStatusWithProgressResult {
419 public STATUS status; /** Current value of this account's P_STATUS property */
420 public int progress; /** This argument returns 0. <br> */
421 }
422
423 /**
424 Recognized values for the P_CBLSYNCSTATUS property. CBL stands for Central Buddy List. In principle, this property and its states can be ignored by most UI developers. However, it can help to optimize UI buildup and behaviour, particularly in case of limited resources (such as mobile devices). <br><br>CBL is used to backup your contact list, contact groups, and profile information, and also used to synchronize this information with other Skype instances of your account (i.e. on another device). CBL sync can occur both during login and during normal operation. Note that CBL synchronization does not take place immediately after an Account property is changed. A delay between the first property change and CBL sync initiation enables the client to accumulate changes and do the synchronization in bulk. <br><br>Clients with limited resources might want to wait for CBL_IN_SYNC status before generating their UI's contact list representation. Otherwise it might be forced to redraw the contact list multiple times, as new updates get retrieved from the server-side. Similarly, applications that modify an account's mood message might want to know when the P_MOOD_TEXT or P_RICH_MOOD_TEXT property is synchronized to the server. Note that this sync is only for CBL and other logged in instances of the same account - other contacts will receive the mood message update directly. <br> */
425 public enum CBLSYNCSTATUS {
426
427 /** status is not clear (yet)*/
428 CBL_INITIALIZING(0),
429
430 /** first sync with empty profile*/
431 CBL_INITIAL_SYNC_PENDING(1),
432
433 /** Account properties are considered to be out of sync with CBL - attempt at synchronization is imminent. You might wish to wait with updating UI components that display the data that is about to change anyway.*/
434 CBL_SYNC_PENDING(2),
435
436 /** CBL synchronization is currently taking place.*/
437 CBL_SYNC_IN_PROGRESS(3),
438
439 /** Account properties are up-to-date.*/
440 CBL_IN_SYNC(4),
441
442 /** CBL sync has. Another attempt will be made after several minutes. If a second attempt also fails, subsequent attempts at synchronization will be made at ever increasing intervals.*/
443 CBL_SYNC_FAILED(5),
444
445 /** we have received a hint that there is a remote data change in CBL*/
446 CBL_REMOTE_SYNC_PENDING(6);
447
448 private static final Map<Integer,CBLSYNCSTATUS> lookup = new HashMap<Integer,CBLSYNCSTATUS>();
449
450 static {
451 for(CBLSYNCSTATUS s : EnumSet.allOf(CBLSYNCSTATUS.class))
452 lookup.put(s.getId(), s);
453 }
454
455 private final int id;
456
457 private CBLSYNCSTATUS(int value) {
458 this.id = value;
459 }
460
461 public int getId() { return id; }
462
463 public static CBLSYNCSTATUS get(int code) {
464 return lookup.get(code);
465 }
466
467 public static CBLSYNCSTATUS fromString(String s) {
468 for (CBLSYNCSTATUS p : lookup.values()) {
469 if (p.toString() == s) {
470 return p;
471 }
472 }
473 return null;
474 }
475 }
476
477 /**
478 Recognized values for the Account.P_LOGOUTREASON. Note that this property should only be examined when Account.P_STATUS is LOGGED_OUT or LOGGED_OUT_AND_PWD_SAVED. That is, you should not monitor changes to this property in Account.OnChange callback, other than after already having checked that P_STATUS property has appropriate value. The reason for this is that the LOGOUTREASON does not get reset before the next login attempt. For example: if a user tried to log in with a wrong password, the LOGOUTREASON gets set to INCORRECT_PASSWORD. Now, if the user tries to log in again, and yet again submits an incorrect password, the value of the LOGOUTREASON does not change anymore, because it already is set to INCORRECT_PASSWORD. Consequently, Account.OnChange will not fire in this case. <br> */
479 public enum LOGOUTREASON {
480
481 /** manual logout (or unknown reason from previous session)*/
482 LOGOUT_CALLED(1),
483
484 /** sync errors at login/registration*/
485 HTTPS_PROXY_AUTH_FAILED(2),
486
487 /** sync errors at login/registration*/
488 SOCKS_PROXY_AUTH_FAILED(3),
489
490 /** sync errors at login/registration*/
491 P2P_CONNECT_FAILED(4),
492
493 /** sync errors at login/registration*/
494 SERVER_CONNECT_FAILED(5),
495
496 /** sync errors at login/registration*/
497 SERVER_OVERLOADED(6),
498
499 /** sync errors at login/registration*/
500 DB_IN_USE(7),
501
502 /** sync errors at registration*/
503 INVALID_SKYPENAME(8),
504
505 /** sync errors at registration*/
506 INVALID_EMAIL(9),
507
508 /** sync errors at registration*/
509 UNACCEPTABLE_PASSWORD(10),
510
511 /** sync errors at registration*/
512 SKYPENAME_TAKEN(11),
513
514 /** sync errors at registration*/
515 REJECTED_AS_UNDERAGE(12),
516
517 /** sync errors at login*/
518 NO_SUCH_IDENTITY(13),
519
520 /** sync errors at login*/
521 INCORRECT_PASSWORD(14),
522
523 /** sync errors at login*/
524 TOO_MANY_LOGIN_ATTEMPTS(15),
525
526 /** async errors (can happen anytime while logged in)*/
527 PASSWORD_HAS_CHANGED(16),
528
529 /** async errors (can happen anytime while logged in)*/
530 PERIODIC_UIC_UPDATE_FAILED(17),
531
532 /** async errors (can happen anytime while logged in)*/
533 DB_DISK_FULL(18),
534
535 /** async errors (can happen anytime while logged in)*/
536 DB_IO_ERROR(19),
537
538 /** async errors (can happen anytime while logged in)*/
539 DB_CORRUPT(20),
540
541 /** deprecated (superceded by more detailed DB_* errors)*/
542 DB_FAILURE(21),
543
544 /** platform sdk*/
545 INVALID_APP_ID(22),
546
547 /** platform sdk*/
548 APP_ID_FAILURE(23),
549
550 /** forced upgrade/discontinuation*/
551 UNSUPPORTED_VERSION(24);
552
553 private static final Map<Integer,LOGOUTREASON> lookup = new HashMap<Integer,LOGOUTREASON>();
554
555 static {
556 for(LOGOUTREASON s : EnumSet.allOf(LOGOUTREASON.class))
557 lookup.put(s.getId(), s);
558 }
559
560 private final int id;
561
562 private LOGOUTREASON(int value) {
563 this.id = value;
564 }
565
566 public int getId() { return id; }
567
568 public static LOGOUTREASON get(int code) {
569 return lookup.get(code);
570 }
571
572 public static LOGOUTREASON fromString(String s) {
573 for (LOGOUTREASON p : lookup.values()) {
574 if (p.toString() == s) {
575 return p;
576 }
577 }
578 return null;
579 }
580 }
581
582 /**
583 *Login an auto-login enabled account (P_STATUS is LOGGED_OUT_AND_PWD_SAVED) and optionally set the availability, for example login in as Contact.DO_NOT_DISTURB. To find out whether there is an auto-login enabled account available, you can use Skype.GetDefaultAccountName to retrieve the skypename of that account. You can then get an Account instance for login by invoking Skype.GetAccount. <br><br>If no accounts with stored login credentials are available (GetDefaultAccountName returns an empty string), then you will have to prompt the user for account name and password and then use LoginWithPassword. Account name field in the UI can be pre-populated with strings retrieved with Skype.GetExistingAccounts <br>
584 * @param setAvailabilityTo force this account's initial online status to the specified Contact.AVAILABILITY value.
585 */
586 public void Login( Contact.AVAILABILITY setAvailabilityTo) {
587
588 Request request = null;
589 try {
590 request = new XCallRequest(5,5);
591 } catch (IOException e) {
592 e.printStackTrace();
593 if (skype.errorListener != null)
594 skype.errorListener.OnSkypeKitFatalError();
595 }
596 request.addParm('O',0,mObjectId);
597 request.addParm('e',1,setAvailabilityTo.getId());
598
599 skype.XCall((XCallRequest)request);
600 }
601
602 /**
603 * <br>Login in an account by specifying its password. To retrieve an account instance for login, invoke Skype.GetAccount. <br>
604 * @param password Password string (plaintext) for this account, which should be pre-validated (Skype.ValidatePassword) <br>
605 * @param savePwd <br> - true: Saves the password, ensuring that auto-login is enabled. <br> - false (default): Does not save the password, and so the user might not be able to effect auto-login until they explicitly invoke Account.SetPasswordSaved(true).
606 * @param saveDataLocally For internal use only.
607 */
608 public void LoginWithPassword( String password, boolean savePwd, boolean saveDataLocally) {
609
610 Request request = null;
611 try {
612 request = new XCallRequest(5,6);
613 } catch (IOException e) {
614 e.printStackTrace();
615 if (skype.errorListener != null)
616 skype.errorListener.OnSkypeKitFatalError();
617 }
618 request.addParm('O',0,mObjectId);
619 request.addParm('S',1,password);
620 request.addParm('b',2,savePwd);
621 request.addParm('b',3,saveDataLocally);
622
623 skype.XCall((XCallRequest)request);
624 }
625
626 /**
627 *This command can be used to create a new Skype account, based on the Account object. When successful, this command will also log in with the newly created account. If the new account registration was not successful, Account status property will change to LOGGED_OUT. A common reason for registration failures is that the an account with that name already exists. In that case, Account LOGOUT_REASON will be set to SKYPENAME_TAKEN. Also, Account SUGGESTED_SKYPENAME property will be set to a list of similar but still available skypenames that could be used instead. The property will contain up to 5 semicolon-separated alternative skypenames. In if no suggested skypenames were available, then this property will contain an empty string. <br>NB! You should pre-validate your P_SKYPENAME value and any email string (Skype.ValidateProfileString) prior to invoking this method. <br>
628 * @param password Password string (plaintext) for this account, which should be pre-validated (Skype.ValidatePassword)
629 * @param savePwd <br> - true: Saves the password and enables auto-login. <br> - false (default): Does not save the password, and the user needs to be prompted for password on the next login attempt.
630 * @param saveDataLocally For internal use only.
631 * @param email An email address for retrieving lost passwords and receiving news and information from Skype.
632 * @param allowSpam enable/disable news and information from Skype being sent to account's e-mail.
633 */
634 public void Register( String password, boolean savePwd, boolean saveDataLocally, String email, boolean allowSpam) {
635
636 Request request = null;
637 try {
638 request = new XCallRequest(5,7);
639 } catch (IOException e) {
640 e.printStackTrace();
641 if (skype.errorListener != null)
642 skype.errorListener.OnSkypeKitFatalError();
643 }
644 request.addParm('O',0,mObjectId);
645 request.addParm('S',1,password);
646 request.addParm('b',2,savePwd);
647 request.addParm('b',3,saveDataLocally);
648 request.addParm('S',4,email);
649 request.addParm('b',5,allowSpam);
650
651 skype.XCall((XCallRequest)request);
652 }
653
654 /**
655 *Logs out current account. Note that calling this on client application exit is optional. <br>
656 * @param clearSavedPwd <br> - true: Clears any saved password use with auto-login and so disables auto-login until you explicitly invoke Account.SetPasswordSaved(true). <br> - false (default): Does not clear any saved password and so does not affect existing auto-login behavior.
657 */
658 public void Logout( boolean clearSavedPwd) {
659
660 Request request = null;
661 try {
662 request = new XCallRequest(5,8);
663 } catch (IOException e) {
664 e.printStackTrace();
665 if (skype.errorListener != null)
666 skype.errorListener.OnSkypeKitFatalError();
667 }
668 request.addParm('O',0,mObjectId);
669 request.addParm('b',1,clearSavedPwd);
670
671 skype.XCall((XCallRequest)request);
672 }
673
674 /**
675 Recognized values for the P_PWDCHANGESTATUS property that provides information on whether a password change succeeded or failed, giving detailed failure reason. After successful return from the Change Password method, clients should monitor the P_PWDCHANGESTATUS property changes. <br> - PWD_CHANGING - consider displaying an "in progress" indicator and continue polling <br> - PWD_OK - consider displaying an updated indicator and stop polling <br> - PWD_OK_BUT_CHANGE_SUGGESTED - consider displaying an updated indicator, along with a recommendation to change again to a stronger password. <br> */
676 public enum PWDCHANGESTATUS {
677
678 /** Password change succeeded. <br>*/
679 PWD_OK(0),
680
681 /** Password change is in progress. <br>*/
682 PWD_CHANGING(1),
683
684 /** Old password was incorrect. <br>*/
685 PWD_INVALID_OLD_PASSWORD(2),
686
687 /** Failed to verify password because of no connection to server. <br>*/
688 PWD_SERVER_CONNECT_FAILED(3),
689
690 /** Password was set but server didn't like it much. <br>*/
691 PWD_OK_BUT_CHANGE_SUGGESTED(4),
692
693 /** New password was exactly the same as old one. <br>*/
694 PWD_MUST_DIFFER_FROM_OLD(5),
695
696 /** The new password was unacceptable. (too short, too simple, etc.) <br>*/
697 PWD_INVALID_NEW_PWD(6),
698
699 /** Account was currently not logged in. <br>*/
700 PWD_MUST_LOG_IN_TO_CHANGE(7);
701
702 private static final Map<Integer,PWDCHANGESTATUS> lookup = new HashMap<Integer,PWDCHANGESTATUS>();
703
704 static {
705 for(PWDCHANGESTATUS s : EnumSet.allOf(PWDCHANGESTATUS.class))
706 lookup.put(s.getId(), s);
707 }
708
709 private final int id;
710
711 private PWDCHANGESTATUS(int value) {
712 this.id = value;
713 }
714
715 public int getId() { return id; }
716
717 public static PWDCHANGESTATUS get(int code) {
718 return lookup.get(code);
719 }
720
721 public static PWDCHANGESTATUS fromString(String s) {
722 for (PWDCHANGESTATUS p : lookup.values()) {
723 if (p.toString() == s) {
724 return p;
725 }
726 }
727 return null;
728 }
729 }
730
731 /**
732 *Changes this account's password. Returns false if the change failed. NB! You should pre-validate your password strings (Skype.ValidatePassword) and ensure that they are different prior to invoking this method. <br>
733 * @param oldPassword "Current password string (plaintext) for this account
734 * @param newPassword New password string (plaintext) for this account
735 * @param savePwd <br> - true: Saves the new password and enables auto-login. <br> - false (default): Clears any existing saved password and so the user cannot effect auto-login until they explicitly invoke Account.SetPasswordSaved(true)
736 */
737 public void ChangePassword( String oldPassword, String newPassword, boolean savePwd) {
738
739 Request request = null;
740 try {
741 request = new XCallRequest(5,11);
742 } catch (IOException e) {
743 e.printStackTrace();
744 if (skype.errorListener != null)
745 skype.errorListener.OnSkypeKitFatalError();
746 }
747 request.addParm('O',0,mObjectId);
748 request.addParm('S',1,oldPassword);
749 request.addParm('S',2,newPassword);
750 request.addParm('b',3,savePwd);
751
752 skype.XCall((XCallRequest)request);
753 }
754
755 /**
756 *save or clear credentials for auto-login whilst already logged in
757 * @param savePwd
758 */
759 public void SetPasswordSaved( boolean savePwd) {
760
761 Request request = null;
762 try {
763 request = new XCallRequest(5,25);
764 } catch (IOException e) {
765 e.printStackTrace();
766 if (skype.errorListener != null)
767 skype.errorListener.OnSkypeKitFatalError();
768 }
769 request.addParm('O',0,mObjectId);
770 request.addParm('b',1,savePwd);
771
772 skype.XCall((XCallRequest)request);
773 }
774
775 /**
776 *Setter for integer (and enum) server-side properties. For a list of writeable server-side properties, see the detailed description of the Account class. <br>
777 * @param propKey
778 * @param value
779 */
780 public void SetServersideIntProperty( int propKey, int value) {
781
782 Request request = null;
783 try {
784 request = new XCallRequest(5,12);
785 } catch (IOException e) {
786 e.printStackTrace();
787 if (skype.errorListener != null)
788 skype.errorListener.OnSkypeKitFatalError();
789 }
790 request.addParm('O',0,mObjectId);
791 request.addParm('e',1,propKey);
792 request.addParm('u',2,value);
793
794 skype.XCall((XCallRequest)request);
795 }
796
797 /**
798 *Setter for String server-side properties. For a list of writeable server-side properties, see the detailed description of the Account class. <br>
799 * @param propKey
800 * @param value
801 */
802 public void SetServersideStrProperty( int propKey, String value) {
803
804 Request request = null;
805 try {
806 request = new XCallRequest(5,13);
807 } catch (IOException e) {
808 e.printStackTrace();
809 if (skype.errorListener != null)
810 skype.errorListener.OnSkypeKitFatalError();
811 }
812 request.addParm('O',0,mObjectId);
813 request.addParm('e',1,propKey);
814 request.addParm('S',2,value);
815
816 skype.XCall((XCallRequest)request);
817 }
818
819 /**
820 The list of possible values of Account class COMMITSTATUS property. Note that this property and its values have nothing to do with (automatic) CBL synchronization. Rather, the COMMITSTATUS reflects commit status to account's server side properties initiated with calls to Account class SetServersideIntProperty and Account class SetServersideStrProperty methods. After those methods, your client UI may want to wait until the COMMITSTATUS becomes COMMITTING_TO_SERVER followed by COMMITTED and inform the user if the value becomes COMMIT_FAILED. SetServerside<type>Property methods are used for writing privacy policy related and call forwarding related Account properties to the server. Unlike CBL synchronization, those updates are executed immediately. <br> */
821 public enum COMMITSTATUS {
822
823 /** No pending updates to the server. <br>*/
824 COMMITTED(1),
825
826 /** Update to the server in progress. <br>*/
827 COMMITTING_TO_SERVER(2),
828
829 /** Server update has failed. <br>*/
830 COMMIT_FAILED(3);
831
832 private static final Map<Integer,COMMITSTATUS> lookup = new HashMap<Integer,COMMITSTATUS>();
833
834 static {
835 for(COMMITSTATUS s : EnumSet.allOf(COMMITSTATUS.class))
836 lookup.put(s.getId(), s);
837 }
838
839 private final int id;
840
841 private COMMITSTATUS(int value) {
842 this.id = value;
843 }
844
845 public int getId() { return id; }
846
847 public static COMMITSTATUS get(int code) {
848 return lookup.get(code);
849 }
850
851 public static COMMITSTATUS fromString(String s) {
852 for (COMMITSTATUS p : lookup.values()) {
853 if (p.toString() == s) {
854 return p;
855 }
856 }
857 return null;
858 }
859 }
860
861 /**
862 *Cancels an attempt to commit a server-side P_XXX_POLICY or the P_OFFLINE_CALLFORWARD server-side property. Invoking this cancellation only makes sense whilst the P_COMMITTSTATUS is in COMMITTING_TO_SERVER state. <br>
863 */
864 public void CancelServerCommit() {
865
866 Request request = null;
867 try {
868 request = new XCallRequest(5,15);
869 } catch (IOException e) {
870 e.printStackTrace();
871 if (skype.errorListener != null)
872 skype.errorListener.OnSkypeKitFatalError();
873 }
874 request.addParm('O',0,mObjectId);
875
876 skype.XCall((XCallRequest)request);
877 }
878
879 /**
880 Recognized values for the P_CHAT_POLICY property that controls whether non-authorized users can initiate text chat with the currently logged in account. Note that since this set of values is associated with a server-side property, you must set that property using Account.SetServersideIntProperty <br> */
881 public enum CHATPOLICY {
882
883 /** Unauthorized contacts can initiate text chat. <br>*/
884 EVERYONE_CAN_ADD(0),
885
886 /** Only authorized contacts can initiate chat (default policy). <br>*/
887 BUDDIES_OR_AUTHORIZED_CAN_ADD(2);
888
889 private static final Map<Integer,CHATPOLICY> lookup = new HashMap<Integer,CHATPOLICY>();
890
891 static {
892 for(CHATPOLICY s : EnumSet.allOf(CHATPOLICY.class))
893 lookup.put(s.getId(), s);
894 }
895
896 private final int id;
897
898 private CHATPOLICY(int value) {
899 this.id = value;
900 }
901
902 public int getId() { return id; }
903
904 public static CHATPOLICY get(int code) {
905 return lookup.get(code);
906 }
907
908 public static CHATPOLICY fromString(String s) {
909 for (CHATPOLICY p : lookup.values()) {
910 if (p.toString() == s) {
911 return p;
912 }
913 }
914 return null;
915 }
916 }
917
918 /**
919 Recognized values for the P_SKYPECALLPOLICY property that controls acceptance of incoming Skype calls. Note that since this set of values is associated with a server-side property, you must set that property using Account.SetServersideIntPropertyserver-side. <br> */
920 public enum SKYPECALLPOLICY {
921
922 /** Skype calls accepted from unauthorized contacts.*/
923 EVERYONE_CAN_CALL(0),
924
925 /** Skype calls not accepted from unauthorized contacts.*/
926 BUDDIES_OR_AUTHORIZED_CAN_CALL(2);
927
928 private static final Map<Integer,SKYPECALLPOLICY> lookup = new HashMap<Integer,SKYPECALLPOLICY>();
929
930 static {
931 for(SKYPECALLPOLICY s : EnumSet.allOf(SKYPECALLPOLICY.class))
932 lookup.put(s.getId(), s);
933 }
934
935 private final int id;
936
937 private SKYPECALLPOLICY(int value) {
938 this.id = value;
939 }
940
941 public int getId() { return id; }
942
943 public static SKYPECALLPOLICY get(int code) {
944 return lookup.get(code);
945 }
946
947 public static SKYPECALLPOLICY fromString(String s) {
948 for (SKYPECALLPOLICY p : lookup.values()) {
949 if (p.toString() == s) {
950 return p;
951 }
952 }
953 return null;
954 }
955 }
956
957 /**
958 Recognized values for the P_PSTNCALLPOLICY property that controls whether (and from whom) this account accepts incoming PSTN calls. Note that since this set of values is associated with a server-side property, you must set that property using Account.SetServersideIntProperty <br> */
959 public enum PSTNCALLPOLICY {
960
961 /** All incoming PSTN calls are accepted.*/
962 ALL_NUMBERS_CAN_CALL(0),
963
964 /** Only PSTN calls that report caller ID are accepted.*/
965 DISCLOSED_NUMBERS_CAN_CALL(1),
966
967 /** Only calls from PSTN numbers found in local contact list are accepted.*/
968 BUDDY_NUMBERS_CAN_CALL(2);
969
970 private static final Map<Integer,PSTNCALLPOLICY> lookup = new HashMap<Integer,PSTNCALLPOLICY>();
971
972 static {
973 for(PSTNCALLPOLICY s : EnumSet.allOf(PSTNCALLPOLICY.class))
974 lookup.put(s.getId(), s);
975 }
976
977 private final int id;
978
979 private PSTNCALLPOLICY(int value) {
980 this.id = value;
981 }
982
983 public int getId() { return id; }
984
985 public static PSTNCALLPOLICY get(int code) {
986 return lookup.get(code);
987 }
988
989 public static PSTNCALLPOLICY fromString(String s) {
990 for (PSTNCALLPOLICY p : lookup.values()) {
991 if (p.toString() == s) {
992 return p;
993 }
994 }
995 return null;
996 }
997 }
998
999 /**
1000 Recognized values for the P_AVATAR_POLICY property that controls whether remote contacts can view local account's avatar image. Note that since this set of values is associated with a server-side property, you must set that property using Account.SetServersideIntPropertyserver-side. <br>Note that setting account's AVATAR_POLICY to BUDDIES_OR_AUTHORIZED_CAN_SEE does not guarantee that remote users will be able to immediately retrieve the avatar picture via corresponding Contact object. Avatar changes propagate between clients only when direct sessions between clients are established. Direct sessions are established during live sessions or whilst online contacts are engaged in chat. <br> */
1001 public enum AVATARPOLICY {
1002
1003 /** Only authorized remote users can see this user's avatar image*/
1004 BUDDIES_OR_AUTHORIZED_CAN_SEE(0),
1005
1006 /** Everyone can see this user's avatar image, once the contact/account avatar property has been synchronized during a direct session. The avatar image may also become viewable on some Skype Web-based services.*/
1007 EVERYONE_CAN_SEE(2);
1008
1009 private static final Map<Integer,AVATARPOLICY> lookup = new HashMap<Integer,AVATARPOLICY>();
1010
1011 static {
1012 for(AVATARPOLICY s : EnumSet.allOf(AVATARPOLICY.class))
1013 lookup.put(s.getId(), s);
1014 }
1015
1016 private final int id;
1017
1018 private AVATARPOLICY(int value) {
1019 this.id = value;
1020 }
1021
1022 public int getId() { return id; }
1023
1024 public static AVATARPOLICY get(int code) {
1025 return lookup.get(code);
1026 }
1027
1028 public static AVATARPOLICY fromString(String s) {
1029 for (AVATARPOLICY p : lookup.values()) {
1030 if (p.toString() == s) {
1031 return p;
1032 }
1033 }
1034 return null;
1035 }
1036 }
1037
1038 /**
1039 Recognized values for the P_BUDDYCOUNT_POLICY property that controls whether the number of this user's authorized contacts is visible to other users, either through Account.GetPropNrofAuthedBuddies or Contact.GetPropNrofAuthedBuddies when those instances reference this user. Note that since this set of values is associated with a server-side property, you must set that property using Account.SetServersideIntProperty, like this: <br>account->SetServersideIntProperty(Account.P_BUDDYCOUNT_POLICY, Account.DISCLOSE_TO_AUTHORIZED); <br>account->SetServersideIntProperty(Account.P_BUDDYCOUNT_POLICY, Account.DISCLOSE_TO_NOONE ); <br> */
1040 public enum BUDDYCOUNTPOLICY {
1041
1042 /** Authorized remote users can retrieve the number of this user's authorized contacts (Contact.P_NROF_AUTHED_BUDDIES)*/
1043 DISCLOSE_TO_AUTHORIZED(0),
1044
1045 /** No remote user - regardless their authorization status - can retrieve the number of this user's authorized contacts. Account.GetPropNrofAuthedBuddies and Contact.GetPropNrofAuthedBuddies will always return 0*/
1046 DISCLOSE_TO_NOONE(1);
1047
1048 private static final Map<Integer,BUDDYCOUNTPOLICY> lookup = new HashMap<Integer,BUDDYCOUNTPOLICY>();
1049
1050 static {
1051 for(BUDDYCOUNTPOLICY s : EnumSet.allOf(BUDDYCOUNTPOLICY.class))
1052 lookup.put(s.getId(), s);
1053 }
1054
1055 private final int id;
1056
1057 private BUDDYCOUNTPOLICY(int value) {
1058 this.id = value;
1059 }
1060
1061 public int getId() { return id; }
1062
1063 public static BUDDYCOUNTPOLICY get(int code) {
1064 return lookup.get(code);
1065 }
1066
1067 public static BUDDYCOUNTPOLICY fromString(String s) {
1068 for (BUDDYCOUNTPOLICY p : lookup.values()) {
1069 if (p.toString() == s) {
1070 return p;
1071 }
1072 }
1073 return null;
1074 }
1075 }
1076
1077 /**
1078 Recognized values for the P_TIMEZONEPOLICY property that sets the rules for timezone offset so remote clients can determine your local time. Note that since this set of values is associated with a server-side property, you must set that property using Account.SetServersideIntPropertyserver-side. */
1079 public enum TIMEZONEPOLICY {
1080
1081 /** Account's timezone setting is determined automatically. <br>*/
1082 TZ_AUTOMATIC(0),
1083
1084 /** Account's timezone setting is set manually. <br>*/
1085 TZ_MANUAL(1),
1086
1087 /** Remote users will have no idea what your local time is. <br>*/
1088 TZ_UNDISCLOSED(2);
1089
1090 private static final Map<Integer,TIMEZONEPOLICY> lookup = new HashMap<Integer,TIMEZONEPOLICY>();
1091
1092 static {
1093 for(TIMEZONEPOLICY s : EnumSet.allOf(TIMEZONEPOLICY.class))
1094 lookup.put(s.getId(), s);
1095 }
1096
1097 private final int id;
1098
1099 private TIMEZONEPOLICY(int value) {
1100 this.id = value;
1101 }
1102
1103 public int getId() { return id; }
1104
1105 public static TIMEZONEPOLICY get(int code) {
1106 return lookup.get(code);
1107 }
1108
1109 public static TIMEZONEPOLICY fromString(String s) {
1110 for (TIMEZONEPOLICY p : lookup.values()) {
1111 if (p.toString() == s) {
1112 return p;
1113 }
1114 }
1115 return null;
1116 }
1117 }
1118
1119 /**
1120 Recognized values for the P_WEBPRESENCEPOLICY property that controls whether your online status (presence) can be seen using the "Skype buttons" ( http://www.skype.com/share/buttons/ ) embedded in web pages. Note that since this set of values is associated with a server-side property, you must set that property using Account.SetServersideIntPropertyserver-side. <br> */
1121 public enum WEBPRESENCEPOLICY {
1122
1123 /** Disable displaying online status on web for this account.*/
1124 WEBPRESENCE_DISABLED(0),
1125
1126 /** Enable displaying online status on web for this account.*/
1127 WEBPRESENCE_ENABLED(1);
1128
1129 private static final Map<Integer,WEBPRESENCEPOLICY> lookup = new HashMap<Integer,WEBPRESENCEPOLICY>();
1130
1131 static {
1132 for(WEBPRESENCEPOLICY s : EnumSet.allOf(WEBPRESENCEPOLICY.class))
1133 lookup.put(s.getId(), s);
1134 }
1135
1136 private final int id;
1137
1138 private WEBPRESENCEPOLICY(int value) {
1139 this.id = value;
1140 }
1141
1142 public int getId() { return id; }
1143
1144 public static WEBPRESENCEPOLICY get(int code) {
1145 return lookup.get(code);
1146 }
1147
1148 public static WEBPRESENCEPOLICY fromString(String s) {
1149 for (WEBPRESENCEPOLICY p : lookup.values()) {
1150 if (p.toString() == s) {
1151 return p;
1152 }
1153 }
1154 return null;
1155 }
1156 }
1157
1158 /**
1159 Recognized values for the P_PHONENUMBERSPOLICY property that controls whether unauthorized remote users can see associated phone numbers in their UI (for reference, see the different phone number tabs in Windows desktop Client contact view). Note that since this set of values is associated with a server-side property, you must set that property using Account.SetServersideIntProperty <br> */
1160 public enum PHONENUMBERSPOLICY {
1161
1162 /** Only authorized contacts can see the phone numbers.*/
1163 PHONENUMBERS_VISIBLE_FOR_BUDDIES(0),
1164
1165 /** Everyone can see the phone numbers.*/
1166 PHONENUMBERS_VISIBLE_FOR_EVERYONE(1);
1167
1168 private static final Map<Integer,PHONENUMBERSPOLICY> lookup = new HashMap<Integer,PHONENUMBERSPOLICY>();
1169
1170 static {
1171 for(PHONENUMBERSPOLICY s : EnumSet.allOf(PHONENUMBERSPOLICY.class))
1172 lookup.put(s.getId(), s);
1173 }
1174
1175 private final int id;
1176
1177 private PHONENUMBERSPOLICY(int value) {
1178 this.id = value;
1179 }
1180
1181 public int getId() { return id; }
1182
1183 public static PHONENUMBERSPOLICY get(int code) {
1184 return lookup.get(code);
1185 }
1186
1187 public static PHONENUMBERSPOLICY fromString(String s) {
1188 for (PHONENUMBERSPOLICY p : lookup.values()) {
1189 if (p.toString() == s) {
1190 return p;
1191 }
1192 }
1193 return null;
1194 }
1195 }
1196
1197 /**
1198 Recognized values for the P_VOICEMAILPOLICY property that controls acceptance of incoming voicemail messages. Note that since this set of values is associated with a server-side property, you must set that property using Account.SetServersideIntPropertyserver-side. <br> */
1199 public enum VOICEMAILPOLICY {
1200
1201 /** Incoming voicemails enabled.*/
1202 VOICEMAIL_ENABLED(0),
1203
1204 /** Incoming voicemails disabled.*/
1205 VOICEMAIL_DISABLED(1);
1206
1207 private static final Map<Integer,VOICEMAILPOLICY> lookup = new HashMap<Integer,VOICEMAILPOLICY>();
1208
1209 static {
1210 for(VOICEMAILPOLICY s : EnumSet.allOf(VOICEMAILPOLICY.class))
1211 lookup.put(s.getId(), s);
1212 }
1213
1214 private final int id;
1215
1216 private VOICEMAILPOLICY(int value) {
1217 this.id = value;
1218 }
1219
1220 public int getId() { return id; }
1221
1222 public static VOICEMAILPOLICY get(int code) {
1223 return lookup.get(code);
1224 }
1225
1226 public static VOICEMAILPOLICY fromString(String s) {
1227 for (VOICEMAILPOLICY p : lookup.values()) {
1228 if (p.toString() == s) {
1229 return p;
1230 }
1231 }
1232 return null;
1233 }
1234 }
1235
1236 /**
1237 *Setter for integer properties. For a list of writeable account profile properties, see the detailed description of the Account class. <br>
1238 * @param propKey
1239 * @param value
1240 */
1241 public void SetIntProperty( int propKey, int value) {
1242
1243 Request request = null;
1244 try {
1245 request = new XCallRequest(5,16);
1246 } catch (IOException e) {
1247 e.printStackTrace();
1248 if (skype.errorListener != null)
1249 skype.errorListener.OnSkypeKitFatalError();
1250 }
1251 request.addParm('O',0,mObjectId);
1252 request.addParm('e',1,propKey);
1253 request.addParm('u',2,value);
1254
1255 skype.XCall((XCallRequest)request);
1256 }
1257
1258 /**
1259 *Setter for String properties. For a list of writeable account profile properties, see the detailed description of the Account class. NB! You should pre-validate your about and mood message strings (Skype.ValidateProfileString) prior to invoking this method. <br>
1260 * @param propKey
1261 * @param value
1262 */
1263 public void SetStrProperty( int propKey, String value) {
1264
1265 Request request = null;
1266 try {
1267 request = new XCallRequest(5,17);
1268 } catch (IOException e) {
1269 e.printStackTrace();
1270 if (skype.errorListener != null)
1271 skype.errorListener.OnSkypeKitFatalError();
1272 }
1273 request.addParm('O',0,mObjectId);
1274 request.addParm('e',1,propKey);
1275 request.addParm('S',2,value);
1276
1277 skype.XCall((XCallRequest)request);
1278 }
1279
1280 /**
1281 *Setter for BLOB properties, such as its avatar image. For a list of writeable account profile properties, see the detailed description of the Account class. NB! You should pre-validate your avatar image (Skype.ValidateAvatar) prior to invoking this method. <br>
1282 * @param propKey
1283 * @param value
1284 */
1285 public void SetBinProperty( int propKey, byte[] value) {
1286
1287 Request request = null;
1288 try {
1289 request = new XCallRequest(5,18);
1290 } catch (IOException e) {
1291 e.printStackTrace();
1292 if (skype.errorListener != null)
1293 skype.errorListener.OnSkypeKitFatalError();
1294 }
1295 request.addParm('O',0,mObjectId);
1296 request.addParm('e',1,propKey);
1297 request.addParm('B',2,value);
1298
1299 skype.XCall((XCallRequest)request);
1300 }
1301
1302 /**
1303 *Sets online status of the currently logged in account to one of the values from Contact class AVAILABILITY enumerator. <br>
1304 * @param availability only subset of all contact availabilities allowed
1305 */
1306 public void SetAvailability( Contact.AVAILABILITY availability) {
1307
1308 Request request = null;
1309 try {
1310 request = new XCallRequest(5,19);
1311 } catch (IOException e) {
1312 e.printStackTrace();
1313 if (skype.errorListener != null)
1314 skype.errorListener.OnSkypeKitFatalError();
1315 }
1316 request.addParm('O',0,mObjectId);
1317 request.addParm('e',1,availability.getId());
1318
1319 skype.XCall((XCallRequest)request);
1320 }
1321
1322 /**
1323 *Transitions the availability of this account's associated user, who is assumed to be logged in. <br>
1324 * @param standby <br> - true: Saves the user's current availability, then sets it to CONTACT.AVAILABILITY.OFFLINE <br> - false: Reconnects the user and restores their previous availability
1325 */
1326 public void SetStandby( boolean standby) {
1327
1328 Request request = null;
1329 try {
1330 request = new XCallRequest(5,10);
1331 } catch (IOException e) {
1332 e.printStackTrace();
1333 if (skype.errorListener != null)
1334 skype.errorListener.OnSkypeKitFatalError();
1335 }
1336 request.addParm('O',0,mObjectId);
1337 request.addParm('b',1,standby);
1338
1339 skype.XCall((XCallRequest)request);
1340 }
1341
1342 /**
1343 Account capabability statuses are possible values of Contact class CAPABILITY enumerator, when that enumerator is used in context of account. Compared to Contact class CAPABILITYSTATUS enums, Account class CAPABILITYSTATUS has additional items for subscription expiration warnings. <br> */
1344 public enum CAPABILITYSTATUS {
1345
1346 /** Capability is not supported by the currently logged in SkypeKit client.*/
1347 NO_CAPABILITY(0),
1348
1349 /** Capability is supported by the currently logged in SkypeKit client. <br>*/
1350 CAPABILITY_EXISTS(1),
1351
1352 /** Support for this capability ends this month (within 30 days) <br>*/
1353 FIRST_EXPIRY_WARNING(2),
1354
1355 /** Support for this capability ends this week (within 7 days) <br>*/
1356 SECOND_EXPIRY_WARNING(3),
1357
1358 /** Support for this capability ends today <br>*/
1359 FINAL_EXPIRY_WARNING(4);
1360
1361 private static final Map<Integer,CAPABILITYSTATUS> lookup = new HashMap<Integer,CAPABILITYSTATUS>();
1362
1363 static {
1364 for(CAPABILITYSTATUS s : EnumSet.allOf(CAPABILITYSTATUS.class))
1365 lookup.put(s.getId(), s);
1366 }
1367
1368 private final int id;
1369
1370 private CAPABILITYSTATUS(int value) {
1371 this.id = value;
1372 }
1373
1374 public int getId() { return id; }
1375
1376 public static CAPABILITYSTATUS get(int code) {
1377 return lookup.get(code);
1378 }
1379
1380 public static CAPABILITYSTATUS fromString(String s) {
1381 for (CAPABILITYSTATUS p : lookup.values()) {
1382 if (p.toString() == s) {
1383 return p;
1384 }
1385 }
1386 return null;
1387 }
1388 }
1389
1390 /**
1391 *Returns state of a given account capability. Takes Contact class CAPABILITY property as input argument and returns its state and expiration timestamp where appropriate. For example (C++ wrapper, with other wrappers the syntax may vary but the idea is the same) MyAccount.GetCapabilityStatus(Contact.CAPABILITY_SKYPEOUT, Cap, T); will return Account.CAPABILITY_EXISTS if local account has SkypeOut enabled. <br>
1392 * @param capability
1393 * @return GetCapabilityStatusResult
1394 */
1395 public GetCapabilityStatusResult GetCapabilityStatus( Contact.CAPABILITY capability) {
1396
1397 Request request = null;
1398 try {
1399 request = new XCallRequest(5,21);
1400 } catch (IOException e) {
1401 e.printStackTrace();
1402 if (skype.errorListener != null)
1403 skype.errorListener.OnSkypeKitFatalError();
1404 }
1405 request.addParm('O',0,mObjectId);
1406 request.addParm('e',1,capability.getId());
1407
1408 Response r = skype.XCall((XCallRequest)request);
1409
1410 if (r.isErrCall())
1411 return null;
1412
1413 GetCapabilityStatusResult result = new GetCapabilityStatusResult();
1414
1415 CAPABILITYSTATUS capabilitystatus = null;
1416 capabilitystatus = CAPABILITYSTATUS.get(r.GetAsInt(1));
1417 result.status = capabilitystatus;
1418
1419 int expiryTimestamp = 0;
1420 expiryTimestamp = r.GetAsInt(2);
1421 result.expiryTimestamp = expiryTimestamp;
1422
1423 return result;
1424 }
1425
1426 public class GetCapabilityStatusResult {
1427 public CAPABILITYSTATUS status;
1428 public int expiryTimestamp;
1429 }
1430
1431 /**
1432 *Response is empty when called with an inactive or invalid account
1433 * @return skypenameHash
1434 */
1435 public String GetSkypenameHash() {
1436
1437 Request request = null;
1438 try {
1439 request = new XCallRequest(5,22);
1440 } catch (IOException e) {
1441 e.printStackTrace();
1442 if (skype.errorListener != null)
1443 skype.errorListener.OnSkypeKitFatalError();
1444 }
1445 request.addParm('O',0,mObjectId);
1446
1447 Response r = skype.XCall((XCallRequest)request);
1448
1449 if (r.isErrCall())
1450 return null;
1451
1452 String skypenameHash = null;
1453 skypenameHash = r.GetAsString(1);
1454 return skypenameHash;
1455 }
1456
1457 /**
1458 *returns verified-by-Skype e-mail for this account if exists and verifiable
1459 * @return email
1460 */
1461 public String GetVerifiedEmail() {
1462
1463 Request request = null;
1464 try {
1465 request = new XCallRequest(5,2);
1466 } catch (IOException e) {
1467 e.printStackTrace();
1468 if (skype.errorListener != null)
1469 skype.errorListener.OnSkypeKitFatalError();
1470 }
1471 request.addParm('O',0,mObjectId);
1472
1473 Response r = skype.XCall((XCallRequest)request);
1474
1475 if (r.isErrCall())
1476 return null;
1477
1478 String email = null;
1479 email = r.GetAsString(1);
1480 return email;
1481 }
1482
1483 /**
1484 *returns verified-by-Skype company for this account if exists and verifiable
1485 * @return company
1486 */
1487 public String GetVerifiedCompany() {
1488
1489 Request request = null;
1490 try {
1491 request = new XCallRequest(5,3);
1492 } catch (IOException e) {
1493 e.printStackTrace();
1494 if (skype.errorListener != null)
1495 skype.errorListener.OnSkypeKitFatalError();
1496 }
1497 request.addParm('O',0,mObjectId);
1498
1499 Response r = skype.XCall((XCallRequest)request);
1500
1501 if (r.isErrCall())
1502 return null;
1503
1504 String company = null;
1505 company = r.GetAsString(1);
1506 return company;
1507 }
1508
1509 /**
1510 *Deletes all account data stored locally. Does not remove any account data from the server! <br>
1511 */
1512 public void Delete() {
1513
1514 Request request = null;
1515 try {
1516 request = new XCallRequest(5,24);
1517 } catch (IOException e) {
1518 e.printStackTrace();
1519 if (skype.errorListener != null)
1520 skype.errorListener.OnSkypeKitFatalError();
1521 }
1522 request.addParm('O',0,mObjectId);
1523
1524 skype.XCall((XCallRequest)request);
1525 }
1526
1527
1528 }