001    package com.skype.api;
002    
003    import java.io.IOException;
004    import java.util.*;
005    import com.skype.ipc.*;
006    /**
007     * Address book entry. Encapsulates methods like GetIdentity, GetAvatar, SendAuthRequest, OpenConversation etc. Single contact can have additional phone numbers attached to it (ASSIGNED_PHONE1 .. ASSIGNED_PHONE3). Note that in the context of a conversation, Contacts are represented by Participant objects. Contact member functions all return a Boolean indicating the success (true) or failure (false) of processing the request itself (transport, runtime availability, and so forth)?not the success or failure of its associated functionality. For example, Contact.IsMemberOf returns true if it was able to make a determination, and its result parameter reflects whether this Contact is a member of the target group. Similarly, Contact.IsMemberOf returns false if it was unable to make a determination, and the value of its result parameter is undefined. <br>
008     */
009    
010    
011    public class Contact extends SkypeObject {
012    
013    
014            public interface ContactListener {
015                    /** This event gets called when there are changes to Contact properties defined in Contact.PROPERTY  */
016                    public void OnPropertyChange(SkypeObject obj, PROPERTY prop, Object value);
017                    
018            }
019            
020            public Contact(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 = 2;
027            
028            public static final int moduleID() {
029                    return MODULE_ID;
030            }
031            
032            /** Properties of the Contact class */
033            public enum PROPERTY {
034            
035                    /** type: Contact.TYPE */
036                    type(202),
037                    
038                    /** defined if it is a SKYPE contact, type: String */
039                    skypename(4),
040                    
041                    /** type: String */
042                    pstnnumber(6),
043                    
044                    /** type: String */
045                    fullname(5),
046                    
047                    /** integer of YYYYMMDD format, type: int */
048                    birthday(7),
049                    
050                    /** 1-male, 2-female, type: int */
051                    gender(8),
052                    
053                    /** ISO language code list, space separated, type: String */
054                    languages(9),
055                    
056                    /** ISO country code, type: String */
057                    country(10),
058                    
059                    /** type: String */
060                    province(11),
061                    
062                    /** type: String */
063                    city(12),
064                    
065                    /** This corresponds to the Account.P_PHONE_HOME property. The value is set by the remote user in Account profile. As Contact property, this is read-only. <br>, type: String */
066                    phone_home(13),
067                    
068                    /** This corresponds to the Account.P_PHONE_OFFICE property. The value is set by the remote user in Account profile. As Contact property, this is read-only. If the Contact has not populated his Account profile with sufficient phone numbers, the UI should implement locally adding additional phone numbers to Contact P_ASSIGNED_PHONE1 .. P_ASSIGNED_PHONE3 properties (and corresponding labels). See Contact.SetPhoneNumber method for more information. <br>, type: String */
069                    phone_office(14),
070                    
071                    /** This corresponds to the Account.P_PHONE_MOBILE property. The value is set by the remote user in Account profile. As Contact property, this is read-only. <br>, type: String */
072                    phone_mobile(15),
073                    
074                    /** will be hashed before advertising/querying, space separated, type: String */
075                    emails(16),
076                    
077                    /** type: String */
078                    homepage(17),
079                    
080                    /** arbitrary introductory text, type: String */
081                    about(18),
082                    
083                    /** Contact avatar pictures are in JPG format. The original size of avatar pictures are in no more than 96 x 96 pixels in size. However, as they can be smaller, scaling the pictures up too much to fit your UI can lead to distorted images. <br>, type: byte[] */
084                    avatar_image(37),
085                    
086                    /** Personal mood message (visible to authorized users only).  <br>, type: String */
087                    mood_text(26),
088                    
089                    /** XML version of personal mood text, type: String */
090                    rich_mood_text(205),
091                    
092                    /** 24*3600+diff_to_UTC_in_seconds. NB! changes with DST <br>, type: int */
093                    timezone(27),
094                    
095                    /** binary tag that can be queried via Contact.HasCapability(), type: byte[] */
096                    capabilities(36),
097                    
098                    /** UNIX timestamp of last profile change, type: int */
099                    profile_timestamp(19),
100                    
101                    /** count of this user's authorized contacts <br>, type: int */
102                    nrof_authed_buddies(28),
103                    
104                    /** ISO country code assigned by the IP, type: String */
105                    ipcountry(29),
106                    
107                    /** UNIX timestamp of when current avatar was set, type: int */
108                    avatar_timestamp(182),
109                    
110                    /** NOT SET FOR CONTACTS. For Account object, UNIX timestamp of when current mood was set, type: int */
111                    mood_timestamp(183),
112                    
113                    /** set if the contact is waiting to be authorized. The value contains auth. request text <br>, type: String */
114                    received_authrequest(20),
115                    
116                    /** timestamp of last received auth-request, type: int */
117                    authreq_timestamp(25),
118                    
119                    /** X timestamp of last successful ping to that user, type: int */
120                    lastonline_timestamp(35),
121                    
122                    /** Contact.AVAILABILITY, type: AVAILABILITY */
123                    availability(34),
124                    
125                    /** always set (assigned by lib by looking at various fields), type: String */
126                    displayname(21),
127                    
128                    /** true if querying additional information from p2p or server <br>, type: boolean */
129                    refreshing(22),
130                    
131                    /** Contact.AUTHLEVEL, change via Contact.GiveAuthlevel(), type: AUTHLEVEL */
132                    given_authlevel(23),
133                    
134                    /** change via Contact.GiveDisplayname(), type: String */
135                    given_displayname(33),
136                    
137                    /** change via Contact.AssignComment(), type: String */
138                    assigned_comment(180),
139                    
140                    /** UNIX timestamp of last outbound session (call, chat, FT, etc), type: int */
141                    lastused_timestamp(39),
142                    
143                    /** for contacts that have CONTACT_RECEIVED_AUTHREQUEST, how many times in a row they have requested it without positive answer, type: int */
144                    authrequest_count(41),
145                    
146                    /** Office phone no. of the contact. This property should NOT be used for SkypeOut contacts <br>, type: String */
147                    assigned_phone1(184),
148                    
149                    /** Value "1" in this property will be translated as "Office" by Skype Windows desktop client, according to UI language settings <br>, type: String */
150                    assigned_phone1_label(185),
151                    
152                    /** Mobile phone no. of the contact <br>, type: String */
153                    assigned_phone2(186),
154                    
155                    /** Value "2" in this property will be translated as "Mobile" by Skype Windows desktop client, according to UI language settings <br>, type: String */
156                    assigned_phone2_label(187),
157                    
158                    /** "Other phone no. of the contact, type: String */
159                    assigned_phone3(188),
160                    
161                    /** Value "3" in this property will be translated as "Other" by Skype Windows desktop client, according to UI language settings <br>, type: String */
162                    assigned_phone3_label(189),
163                    
164                    /** Contact's order by presence popularity <br>, type: int */
165                    popularity_ord(42);
166                    
167                    private static final Map<Integer,PROPERTY> lookup = new HashMap<Integer,PROPERTY>();
168                    
169                    static {
170                            for(PROPERTY s : EnumSet.allOf(PROPERTY.class))
171                                    lookup.put(s.getId(), s);
172                    }
173                    
174                    private final int id;
175                    
176                    private PROPERTY(int value) {
177                            this.id = value;
178                    }
179                    
180                    public int getId() { return id; }
181                    
182                    public static PROPERTY get(int code) {
183                            return lookup.get(code);
184                    }
185                    
186                    public static PROPERTY fromString(String s) {
187                            for (PROPERTY p : lookup.values()) {
188                                    if (p.toString() == s) {
189                                            return p;
190                                    }
191                            }
192                            return null;
193                    }
194            }
195            
196            public Object GetPropertyAsEnum(int propid) {
197                    return PROPERTY.get(propid);
198            }
199            
200            public String GetStrProperty(PROPERTY prop) {
201                    //check in propcache if so then return
202                    if (mPropCache.containsKey(new Integer(prop.id))){
203                            String value =  (String)mPropCache.get(prop.id);
204                            if (value != null && !(value.length() == 0) ){
205                                    return value;
206                            }
207                    }
208                    //else get from skypekit...
209                    GetPropertyRequest request = new GetPropertyRequest(2, mObjectId, prop.id);
210                    
211                    String string = null;
212                    GetPropertyResponse r = skype.GetProperty(request);
213                    if (r != null){
214                            string = r.GetAsString();
215                    }
216                    
217                    if (string != null)
218                    {
219                            mPropCache.put(new Integer(prop.id), string);
220                    }
221                    return string;
222            }
223            
224            public int GetIntProperty(PROPERTY prop) {
225                    //check in propcache if so then return
226                    if (mPropCache.containsKey(new Integer(prop.id))){
227                            int value = ((Integer)mPropCache.get(prop.id)).intValue();
228                            if (value != 0){
229                                    return value;
230                            }
231                    }
232                    //else get from skypekit...
233                    GetPropertyRequest request = new GetPropertyRequest(moduleID(), mObjectId, prop.id);
234                    
235                    Integer integer = null;
236                    GetPropertyResponse r = skype.GetProperty(request);
237                    if (r != null){
238                            integer  = r.GetAsInt();
239                    }
240                    
241                    if (integer != null)
242                    {
243                            mPropCache.put(new Integer(prop.id), integer);
244                            return integer.intValue();
245                    }
246                    else
247                    {
248                            return 0;
249                    }
250            }
251            
252            public boolean GetBooleanProperty(PROPERTY prop) {
253                    //check in propcache if so then return
254                    if (mPropCache.containsKey(new Integer(prop.id))){
255                            return ((Boolean)mPropCache.get(prop.id)).booleanValue();
256                    }
257                    //else get from skypekit...
258                    GetPropertyRequest request = new GetPropertyRequest(moduleID(), mObjectId, prop.id);
259                    
260                    Boolean boolResp = null;
261                    GetPropertyResponse r = skype.GetProperty(request);
262                    if (r != null){
263                            boolResp  = r.GetAsBoolean();
264                    }
265                    
266                    if (boolResp != null)
267                    {
268                            mPropCache.put(new Integer(prop.id), boolResp);
269                            return boolResp.booleanValue();
270                    }
271                    else
272                    {
273                            return false;
274                    }
275            }
276            
277            public byte [] GetBinProperty(PROPERTY prop) {
278                    //get from skypekit...
279                    GetPropertyRequest request = new GetPropertyRequest(2, mObjectId, prop.id);
280                    
281                    byte [] data = null;
282                    GetPropertyResponse r = skype.GetProperty(request);
283                    if (r != null) {
284                            data = r.GetAsBinary();
285                    }
286                    return data;
287            }
288            
289            /**default array of Contact Properties that get fetched & cached upon class construction*/
290            private static PROPERTY [] defaultProperties = { PROPERTY.type, PROPERTY.skypename, PROPERTY.fullname, PROPERTY.displayname, PROPERTY.mood_text, PROPERTY.pstnnumber, PROPERTY.availability, PROPERTY.given_displayname};
291            
292            private void GetDefaultProps() {
293                    MultiGetPropertyRequest request = null;
294                    ArrayList<Integer> proparray = null;
295                            /**Add the single oid into array*/
296                            ArrayList<Integer> oidarray=new ArrayList<Integer>();
297                            oidarray.add(mObjectId);
298                            
299                            /**Add all requested propids into array*/
300                            proparray=new ArrayList<Integer>();
301                            for (PROPERTY defaultProp : defaultProperties) {
302                                    proparray.add(defaultProp.getId());
303                            }
304                            /**Generate the request*/
305                            request = new MultiGetPropertyRequest(moduleID(), oidarray,proparray);
306                            
307                            /** Make Multi Get call*/
308                            GetPropertyResponse r=skype.MultiGetProperty(request);
309                            /**Verify that it is a proper multiresponse*/
310                            if(!r.isMultiresponse())
311                            {
312                                    return;
313                            }
314                            /**update property cache with results*/
315                            mPropCache.putAll(r.GetAsMap(mObjectId, proparray));
316                    }
317                    
318                    /**
319                    Same as with CAPABILITY, enumerator is used by both Contact and Account objects. <br> */
320                    public enum TYPE {
321                    
322                            /** Contact/account has no pre-identified type. This type is reported by default for SkypeKit clients. <br>*/
323                            UNRECOGNIZED(0),
324                            
325                            /** Normal Skype contact. <br>*/
326                            SKYPE(1),
327                            
328                            /** Normal PSTN contact. <br>*/
329                            PSTN(2),
330                            
331                            /** Emergency number (i.e. 911). <br>*/
332                            EMERGENCY_PSTN(3),
333                            
334                            /** */
335                            FREE_PSTN(4),
336                            
337                            /** Undisclosed PSTN number. <br>*/
338                            UNDISCLOSED_PSTN(5),
339                            
340                            /** This type is currently used by Windows desktop clients for contacts imported from Outlook. <br>*/
341                            EXTERNAL(6);
342                            
343                            private static final Map<Integer,TYPE> lookup = new HashMap<Integer,TYPE>();
344                            
345                            static {
346                                    for(TYPE s : EnumSet.allOf(TYPE.class))
347                                            lookup.put(s.getId(), s);
348                            }
349                            
350                            private final int id;
351                            
352                            private TYPE(int value) {
353                                    this.id = value;
354                            }
355                            
356                            public int getId() { return id; }
357                            
358                            public static TYPE get(int code) {
359                                    return lookup.get(code);
360                            }
361                            
362                            public static TYPE fromString(String s) {
363                                    for (TYPE p : lookup.values()) {
364                                            if (p.toString() == s) {
365                                                    return p;
366                                            }
367                                    }
368                                    return null;
369                            }
370                    }
371                    
372                    /**
373                    Describes the recognized relational states between a local account and a remote contact. <br> */
374                    public enum AUTHLEVEL {
375                    
376                            /** Authorization request is either ignored or pending. In this state several functionalities may be blocked, depending on settings. For example, accounts may only allow seeing online presence to be viewable or only receive calls from authorized contacts. <br>*/
377                            NONE(0),
378                            
379                            /** Contact has been authorized by the local account. <br>*/
380                            AUTHORIZED_BY_ME(1),
381                            
382                            /** Contact has been blocked by the local account. This prevents incoming calls, chat messages, additional authorization requests etc. <br>*/
383                            BLOCKED_BY_ME(2);
384                            
385                            private static final Map<Integer,AUTHLEVEL> lookup = new HashMap<Integer,AUTHLEVEL>();
386                            
387                            static {
388                                    for(AUTHLEVEL s : EnumSet.allOf(AUTHLEVEL.class))
389                                            lookup.put(s.getId(), s);
390                            }
391                            
392                            private final int id;
393                            
394                            private AUTHLEVEL(int value) {
395                                    this.id = value;
396                            }
397                            
398                            public int getId() { return id; }
399                            
400                            public static AUTHLEVEL get(int code) {
401                                    return lookup.get(code);
402                            }
403                            
404                            public static AUTHLEVEL fromString(String s) {
405                                    for (AUTHLEVEL p : lookup.values()) {
406                                            if (p.toString() == s) {
407                                                    return p;
408                                            }
409                                    }
410                                    return null;
411                            }
412                    }
413                    
414                    /**
415                    Describes the superset list of possible Account and Contact online statuses. In case of Account they apply to local user, in case of Contact they apply to remote contacts. <br> */
416                    public enum AVAILABILITY {
417                    
418                            /** Contact online status cannot be determined. This availability state should not normally reach the SkypeKit UI level. <br>*/
419                            UNKNOWN(0),
420                            
421                            /** Seeing Contact online status is blocked because authorization between contact and local account has not taken place. <br>*/
422                            PENDINGAUTH(8),
423                            
424                            /** Remote contact has been blocked by local account. This applies to online accounts. <br>*/
425                            BLOCKED(9),
426                            
427                            /** Remote SkypeOut contact has been blocked by local account. <br>*/
428                            BLOCKED_SKYPEOUT(11),
429                            
430                            /** Contact does not have an online status because he is a PSTN contact. <br>*/
431                            SKYPEOUT(10),
432                            
433                            /** Contact appears to be offline. <br>*/
434                            OFFLINE(1),
435                            
436                            /** Contact appears to be offline but has voicemail enabled. <br>*/
437                            OFFLINE_BUT_VM_ABLE(12),
438                            
439                            /** Contact appears to be offline but has enabled call forwarding, so calls may actually get through to him. <br>*/
440                            OFFLINE_BUT_CF_ABLE(13),
441                            
442                            /** Contact / Account is online <br>*/
443                            ONLINE(2),
444                            
445                            /** Contact / Account is online but away from keyboard. This can be either turned on manually or by automatic timer. In Windows desktop client, the timer can be configured with minute precision. <br>*/
446                            AWAY(3),
447                            
448                            /** This online status is marked as deprecated. If a remote contact indicates its status as NOT_AVAILABLE, the UI should handle this as equivalent of AWAY status. <br>*/
449                            NOT_AVAILABLE(4),
450                            
451                            /** Contact / Account is online but does not wish to be disturbed. This status supersedes AWAY status when the account is DO_NOT_DISTURB the AWAY timer should not modify the status. <br>*/
452                            DO_NOT_DISTURB(5),
453                            
454                            /** This online status is marked as deprecated. If a remote contact indicates its status as SKYPE_ME, the UI should handle this as equivalent of ONLINE status. <br>*/
455                            SKYPE_ME(7),
456                            
457                            /** Account status is set to INVISIBLE. This status in not applicable to remote Contacts. When the remote contact has set his availability to INVISIBLE, he will appear as OFFLINE to others. <br>*/
458                            INVISIBLE(6),
459                            
460                            /** only possible for local user/account*/
461                            CONNECTING(14),
462                            
463                            /** */
464                            ONLINE_FROM_MOBILE(15),
465                            
466                            /** *_FROM_MOBILE only possible for remote user*/
467                            AWAY_FROM_MOBILE(16),
468                            
469                            /** */
470                            NOT_AVAILABLE_FROM_MOBILE(17),
471                            
472                            /** */
473                            DO_NOT_DISTURB_FROM_MOBILE(18),
474                            
475                            /** */
476                            SKYPE_ME_FROM_MOBILE(20);
477                            
478                            private static final Map<Integer,AVAILABILITY> lookup = new HashMap<Integer,AVAILABILITY>();
479                            
480                            static {
481                                    for(AVAILABILITY s : EnumSet.allOf(AVAILABILITY.class))
482                                            lookup.put(s.getId(), s);
483                            }
484                            
485                            private final int id;
486                            
487                            private AVAILABILITY(int value) {
488                                    this.id = value;
489                            }
490                            
491                            public int getId() { return id; }
492                            
493                            public static AVAILABILITY get(int code) {
494                                    return lookup.get(code);
495                            }
496                            
497                            public static AVAILABILITY fromString(String s) {
498                                    for (AVAILABILITY p : lookup.values()) {
499                                            if (p.toString() == s) {
500                                                    return p;
501                                            }
502                                    }
503                                    return null;
504                            }
505                    }
506                    
507                    /**
508                     * @return identity returns CONTACT_SKYPENAME or CONTACT_PSTNNUMBER value
509                     */
510                    public String GetIdentity() {
511                    
512                            Request request = null;
513                            try {
514                                    request = new XCallRequest(2,2);
515                            } catch (IOException e) {
516                                    e.printStackTrace();
517                                    if (skype.errorListener != null)
518                                            skype.errorListener.OnSkypeKitFatalError();
519                            }
520                            request.addParm('O',0,mObjectId);
521                            
522                            Response r = skype.XCall((XCallRequest)request);
523                            
524                            if (r.isErrCall())
525                                    return null;
526                                    
527                            String identity = null;
528                            identity = r.GetAsString(1);
529                            return identity;
530                    }
531                    
532                    /**
533                     *Returns Conrtact's avatar image (JPG). <br>
534                     * @return GetAvatarResult
535                     */
536                    public GetAvatarResult GetAvatar() {
537                    
538                            Request request = null;
539                            try {
540                                    request = new XCallRequest(2,4);
541                            } catch (IOException e) {
542                                    e.printStackTrace();
543                                    if (skype.errorListener != null)
544                                            skype.errorListener.OnSkypeKitFatalError();
545                            }
546                            request.addParm('O',0,mObjectId);
547                            
548                            Response r = skype.XCall((XCallRequest)request);
549                            
550                            if (r.isErrCall())
551                                    return null;
552                                    
553                            GetAvatarResult result = new GetAvatarResult();
554                            
555                            boolean present = false;
556                            present = r.GetAsBoolean(1);
557                            result.present = present;
558                            
559                            byte[] avatar = null;
560                            avatar = r.GetAsBinary(2);
561                            result.avatar = avatar;
562                            
563                            return result;
564                    }
565                    
566                    public class GetAvatarResult {
567                            public boolean present; /** <br> - true: the Contact has a custom avatar image <br> - false: the Contact does not have a custom avatar image <br> */
568                            public byte[] avatar; /** The avatar image data (JPG). If present is false, this will be the Skype-assigned default avatar <br> */
569                    }
570                    
571                    /**
572                     *returns verified-by-Skype e-mail for this contact if exists and verifiable
573                     * @return email
574                     */
575                    public String GetVerifiedEmail() {
576                    
577                            Request request = null;
578                            try {
579                                    request = new XCallRequest(2,3);
580                            } catch (IOException e) {
581                                    e.printStackTrace();
582                                    if (skype.errorListener != null)
583                                            skype.errorListener.OnSkypeKitFatalError();
584                            }
585                            request.addParm('O',0,mObjectId);
586                            
587                            Response r = skype.XCall((XCallRequest)request);
588                            
589                            if (r.isErrCall())
590                                    return null;
591                                    
592                            String email = null;
593                            email = r.GetAsString(1);
594                            return email;
595                    }
596                    
597                    /**
598                     *returns verified-by-Skype company for this contact if exists and verifiable
599                     * @return company
600                     */
601                    public String GetVerifiedCompany() {
602                    
603                            Request request = null;
604                            try {
605                                    request = new XCallRequest(2,8);
606                            } catch (IOException e) {
607                                    e.printStackTrace();
608                                    if (skype.errorListener != null)
609                                            skype.errorListener.OnSkypeKitFatalError();
610                            }
611                            request.addParm('O',0,mObjectId);
612                            
613                            Response r = skype.XCall((XCallRequest)request);
614                            
615                            if (r.isErrCall())
616                                    return null;
617                                    
618                            String company = null;
619                            company = r.GetAsString(1);
620                            return company;
621                    }
622                    
623                    /**
624                     *Checks whether the contact is member of a contact group given in group reference argument. <br>
625                     * @param group The target contact group <br>
626                     * @return result <br> - true: the Contact is a member of the target contact group <br> - false: the Contact is not a member of the target contact group <br>
627                     */
628                    public boolean IsMemberOf( ContactGroup group) {
629                    
630                            Request request = null;
631                            try {
632                                    request = new XCallRequest(2,6);
633                            } catch (IOException e) {
634                                    e.printStackTrace();
635                                    if (skype.errorListener != null)
636                                            skype.errorListener.OnSkypeKitFatalError();
637                            }
638                            request.addParm('O',0,mObjectId);
639                            request.addParm('O',1,group.getOid());
640                            
641                            Response r = skype.XCall((XCallRequest)request);
642                            
643                            if (r.isErrCall())
644                                    return false;
645                                    
646                            boolean result = false;
647                            result = r.GetAsBoolean(1);
648                            return result;
649                    }
650                    
651                    /**
652                     *Checks whether the contact is member of a pre-defined contact group given in the TYPE argument (type for this property comes from the ContactGroup class). <br>
653                     * @param groupType The type designator of the target pre-defined contact group. For example, specify this parameter as ContactGroup.TYPE.RECENTLY_CONTACTED_CONTACTS to determine if you've had a recent conversation with this Contact. <br>
654                     * @return result <br> - true: the Contact is a member of the target contact group <br> - false: the Contact is not a member of the target contact group <br>
655                     */
656                    public boolean IsMemberOfHardwiredGroup( ContactGroup.TYPE groupType) {
657                    
658                            Request request = null;
659                            try {
660                                    request = new XCallRequest(2,7);
661                            } catch (IOException e) {
662                                    e.printStackTrace();
663                                    if (skype.errorListener != null)
664                                            skype.errorListener.OnSkypeKitFatalError();
665                            }
666                            request.addParm('O',0,mObjectId);
667                            request.addParm('e',1,groupType.getId());
668                            
669                            Response r = skype.XCall((XCallRequest)request);
670                            
671                            if (r.isErrCall())
672                                    return false;
673                                    
674                            boolean result = false;
675                            result = r.GetAsBoolean(1);
676                            return result;
677                    }
678                    
679                    /**
680                     *Blocks or unblocks any further incoming communication attempts from this contact. <br>
681                     * @param blocked <br> - true: block this contact <br> - false: unblock this contact <br>
682                     * @param abuse Optional parameter to report abuse by this Skype user when blocking this Contact. Note that you can specifiy this parameter as true only when blocking a Contact. Defaults to false if omitted. <br>
683                     */
684                    public void SetBlocked( boolean blocked, boolean abuse) {
685                    
686                            Request request = null;
687                            try {
688                                    request = new XCallRequest(2,22);
689                            } catch (IOException e) {
690                                    e.printStackTrace();
691                                    if (skype.errorListener != null)
692                                            skype.errorListener.OnSkypeKitFatalError();
693                            }
694                            request.addParm('O',0,mObjectId);
695                            request.addParm('b',1,blocked);
696                            request.addParm('b',2,abuse);
697                            
698                            skype.XCall((XCallRequest)request);
699                    }
700                    
701                    /**
702                     *Rejects and removes a pending authorization request from this Contact. <br>
703                     */
704                    public void IgnoreAuthRequest() {
705                    
706                            Request request = null;
707                            try {
708                                    request = new XCallRequest(2,21);
709                            } catch (IOException e) {
710                                    e.printStackTrace();
711                                    if (skype.errorListener != null)
712                                            skype.errorListener.OnSkypeKitFatalError();
713                            }
714                            request.addParm('O',0,mObjectId);
715                            
716                            skype.XCall((XCallRequest)request);
717                    }
718                    
719                    /**
720                     *sets CONTACT_GIVEN_DISPLAYNAME. clears if size(name)==0
721                     * @param name
722                     */
723                    public void GiveDisplayName( String name) {
724                    
725                            Request request = null;
726                            try {
727                                    request = new XCallRequest(2,10);
728                            } catch (IOException e) {
729                                    e.printStackTrace();
730                                    if (skype.errorListener != null)
731                                            skype.errorListener.OnSkypeKitFatalError();
732                            }
733                            request.addParm('O',0,mObjectId);
734                            request.addParm('S',1,name);
735                            
736                            skype.XCall((XCallRequest)request);
737                    }
738                    
739                    /**
740                     *Adds or removes this Contact from the ALL_BUDDIES hardwired group. <br>
741                     * @param isMyBuddy <br> - true: add this contact to the ALL_BUDDIES group <br> - false: delete contact from the ALL_BUDDIES group <br>
742                     * @param syncAuth This argument is deprecated and should not be used. <br>
743                     */
744                    public void SetBuddyStatus( boolean isMyBuddy, boolean syncAuth) {
745                    
746                            Request request = null;
747                            try {
748                                    request = new XCallRequest(2,12);
749                            } catch (IOException e) {
750                                    e.printStackTrace();
751                                    if (skype.errorListener != null)
752                                            skype.errorListener.OnSkypeKitFatalError();
753                            }
754                            request.addParm('O',0,mObjectId);
755                            request.addParm('b',1,isMyBuddy);
756                            request.addParm('b',2,syncAuth);
757                            
758                            skype.XCall((XCallRequest)request);
759                    }
760                    
761                    /**
762                     */
763                    public enum EXTRA_AUTHREQ_FIELDS {
764                    
765                            /** send verified e-mail blob with this auth request*/
766                            SEND_VERIFIED_EMAIL(1),
767                            
768                            /** send verified company blob with this auth request*/
769                            SEND_VERIFIED_COMPANY(2);
770                            
771                            private static final Map<Integer,EXTRA_AUTHREQ_FIELDS> lookup = new HashMap<Integer,EXTRA_AUTHREQ_FIELDS>();
772                            
773                            static {
774                                    for(EXTRA_AUTHREQ_FIELDS s : EnumSet.allOf(EXTRA_AUTHREQ_FIELDS.class))
775                                            lookup.put(s.getId(), s);
776                            }
777                            
778                            private final int id;
779                            
780                            private EXTRA_AUTHREQ_FIELDS(int value) {
781                                    this.id = value;
782                            }
783                            
784                            public int getId() { return id; }
785                            
786                            public static EXTRA_AUTHREQ_FIELDS get(int code) {
787                                    return lookup.get(code);
788                            }
789                            
790                            public static EXTRA_AUTHREQ_FIELDS fromString(String s) {
791                                    for (EXTRA_AUTHREQ_FIELDS p : lookup.values()) {
792                                            if (p.toString() == s) {
793                                                    return p;
794                                            }
795                                    }
796                                    return null;
797                            }
798                    }
799                    
800                    /**
801                     *Sends a contact authorization request to this user. <br>
802                     * @param message Text that typically introduces the requesting user and details the reason for the authorization request. This text will be set as Message.P_BODY_XML property of the notification Message the remote user will receive upon getting the authortization request. While this can be the empty string, it cannot be null. <br>
803                     * @param extras_bitmask Indicates additional information to include with this authorization request: <br> - 0 (zero): do not include any additional information <br> - SEND_VERIFIED_EMAIL: include the requestor's verified e-mail address <br> - SEND_VERIFIED_COMPANY: include verified information regarding the requestor's company <br> - SEND_VERIFIED_EMAIL + SEND_VERIFIED_COMPANY: include both e-mail and company information <br>
804                     */
805                    public void SendAuthRequest( String message, int extras_bitmask) {
806                    
807                            Request request = null;
808                            try {
809                                    request = new XCallRequest(2,13);
810                            } catch (IOException e) {
811                                    e.printStackTrace();
812                                    if (skype.errorListener != null)
813                                            skype.errorListener.OnSkypeKitFatalError();
814                            }
815                            request.addParm('O',0,mObjectId);
816                            request.addParm('S',1,message);
817                            request.addParm('u',2,extras_bitmask);
818                            
819                            skype.XCall((XCallRequest)request);
820                    }
821                    
822                    /**
823                     *the contact has accepted my auth request
824                     * @return result
825                     */
826                    public boolean HasAuthorizedMe() {
827                    
828                            Request request = null;
829                            try {
830                                    request = new XCallRequest(2,14);
831                            } catch (IOException e) {
832                                    e.printStackTrace();
833                                    if (skype.errorListener != null)
834                                            skype.errorListener.OnSkypeKitFatalError();
835                            }
836                            request.addParm('O',0,mObjectId);
837                            
838                            Response r = skype.XCall((XCallRequest)request);
839                            
840                            if (r.isErrCall())
841                                    return false;
842                                    
843                            boolean result = false;
844                            result = r.GetAsBoolean(1);
845                            return result;
846                    }
847                    
848                    /**
849                     *Sets the three P_ASSIGNED_PHONEx and P_ASSIGNED_PHONEx_LABEL properties, where x reflects the value of num.  <br><br>The Skype Windows desktop client uses the following conventions when interpreting and assigning values to these properties. While your solution can assign arbitrary values to these properties, we strongly recommend using these conventions to ensure interoperability with the Skype Windows desktop client. Keep in mind that the "number" of these property pairs has no relationship to how the Skype Windows client interprets their label property value strings. For example, the Skype Windows client will interpret P_ASSIGNED_PHONE3_LABEL as "Home" if its value is the string "0".  <br><br>Label strings: <br><br>Populate the label properties with string representations of the numbers "0" through "3", rather than descriptive strings like "Home", "Mobile", and so forth. The Skype desktop clients interpret the numeric string values as: <br> - "0" (zero) - "Home" <br> - "1" (one) - "Office" <br> - "2" - "Mobile" <br> - "3" - "Other" <br><br>Keep in mind that the "number" of a property pair has no relationship to its label string. For example, the Skype Windows client will interpret P_ASSIGNED_PHONE3_LABEL as "Home" if its value is the string "0". <br><br>Phone number strings: <br><br>The Skype Windows desktop client has distinct conventions for Skype Contacts and PSTN (SkypeOut) Contacts: any or all of the property pairs can be used for Skype Contacts; P_ASSIGNED_PHONE1 cannot be used for PSTN Contacts and P_ASSIGNED_PHONE1_LABEL has special meaning for PSTN Contacts. <br>Specifically, the Skype desktop clients use P_ASSIGNED_PHONE1_LABEL as the label for a PSTN Contact's primary number (regardless of whether it's home, mobile, or office), and use P_PSTNNUMBER to hold the actual number. <br><br>
850                     * @param num The property pair being set, which must be in the range 0..3 <br>
851                     * @param label The label text for the property being set <br>
852                     * @param number The phone number for the property being set <br>
853                     */
854                    public void SetPhoneNumber( int num, String label, String number) {
855                    
856                            Request request = null;
857                            try {
858                                    request = new XCallRequest(2,15);
859                            } catch (IOException e) {
860                                    e.printStackTrace();
861                                    if (skype.errorListener != null)
862                                            skype.errorListener.OnSkypeKitFatalError();
863                            }
864                            request.addParm('O',0,mObjectId);
865                            request.addParm('u',1,num);
866                            request.addParm('S',2,label);
867                            request.addParm('S',3,number);
868                            
869                            skype.XCall((XCallRequest)request);
870                    }
871                    
872                    /**
873                     *Retrieves a dialog conversation with the Contact. <br>
874                     * @return conversation Retrieved dialog. <br>
875                     */
876                    public Conversation OpenConversation() {
877                    
878                            Request request = null;
879                            try {
880                                    request = new XCallRequest(2,17);
881                            } catch (IOException e) {
882                                    e.printStackTrace();
883                                    if (skype.errorListener != null)
884                                            skype.errorListener.OnSkypeKitFatalError();
885                            }
886                            request.addParm('O',0,mObjectId);
887                            
888                            Response r = skype.XCall((XCallRequest)request);
889                            
890                            if (r.isErrCall())
891                                    return null;
892                                    
893                            int oid = 0;
894                            Conversation conversation = null;
895                            oid = r.GetOid(1);
896                            if (oid != AbstractDecoder.NULL_VALUE) {
897                                    conversation = (Conversation)skype.factory(Conversation.moduleID(), oid, skype);
898                            }
899                            return conversation;
900                    }
901                    
902                    /**
903                    This enumerator is used by both Contact and Account objects. Thus the items here can have slightly different meaning, depending on which context you will examine their values. In case of Contact, the values apply to a user - across all the instances that user has logged in with Skype. In case of Account, the capability is that of a local, currently logged in instance of Skype client. <br><br>The values that CAPABILITY items can have are also dependant on class context. In context of Contact, a capability can be CAPABILITY_MIXED. Which in case of CAPABILITY_VIDEO, for example, would mean that the remote use has logged in with different clients, some of which support video calls and some of which don't. In context of Account - there are no mixed result. Currently logged in Skype instance either supports video or it doesn't. <br> */
904                    public enum CAPABILITY {
905                    
906                            /** For Account object, this is the same as CAPABILITY_CAN_BE_SENT_VM - it indicates that the currently logged in Skype instance supports voicemails. For Contact objects, it means that their remote system supports sending voicemails - there is no technical method for Skype to detect whether they are capable of receiving voicemails, so the assumption is that they can. <br>*/
907                            CAPABILITY_VOICEMAIL(0),
908                            
909                            /** Indicates that the contact/account has SkypeOut and is thus capable of making PSTN calls. <br>*/
910                            CAPABILITY_SKYPEOUT(1),
911                            
912                            /** Indicates that the contact/account has SkypeIn and is thus capable of answering PSTN calls. <br>*/
913                            CAPABILITY_SKYPEIN(2),
914                            
915                            /** For contacts, this is a combination of CAPABILITY_VOICEMAIL for local account (local Skype client supports sending voicemails) and CAPABILITY_VOICEMAIL of the Contact - if the contact supports sending voicemails then hopefully they can also receive them. <br>*/
916                            CAPABILITY_CAN_BE_SENT_VM(3),
917                            
918                            /** Indicates that Account/Contact supports call forwarding. <br>*/
919                            CAPABILITY_CALL_FORWARD(4),
920                            
921                            /** Indicates that Account/Contact supports call video calls. <br>*/
922                            CAPABILITY_VIDEO(5),
923                            
924                            /** In context of Contact, this indicates that the user is noticed running at least one Skype implementation that supports text messaging. Basically, it applies to a user. When applied to Account, the meaning is slightly different. In that case it indicates that currently running Skype implementation supports chat messaging. So, for Account objects, this is a node (rather than user) capability. <br>*/
925                            CAPABILITY_TEXT(6),
926                            
927                            /** Indicates that the contact/account is flagged as SkypePrime service provider. This is linked to Account class SERVICE_PROVIDER_INFO property. <br>*/
928                            CAPABILITY_SERVICE_PROVIDER(7),
929                            
930                            /** This is a legacy item, from the old times when conference calls with more than 5 people were limited to SkypePro accounts. In other words, this item is no longer relevant and will likely be removed at some point in future. <br>*/
931                            CAPABILITY_LARGE_CONFERENCE(8),
932                            
933                            /** */
934                            CAPABILITY_COMMERCIAL_CONTACT(9),
935                            
936                            /** Indicates that Account/Contact supports call transfers to PSTN numbers. <br>*/
937                            CAPABILITY_PSTN_TRANSFER(10),
938                            
939                            /** Indicates that the user has had his chat capability removed by Skype. Basically, this means that the user is reported as spammer too many times. This applies for both Contact and Account objects - which means your client can check locally, if the currently logged in user has been marked as a spammer. <br>*/
940                            CAPABILITY_TEXT_EVER(11),
941                            
942                            /** Indicates that the user (Account or Contact) has had his voice call capability removed by Skype. <br>*/
943                            CAPABILITY_VOICE_EVER(12),
944                            
945                            /** Indicates that the instance of Skype client Account/Contact is or in Contact's case has at least occasionally been flagged as a mobile device. <br>*/
946                            CAPABILITY_MOBILE_DEVICE(13),
947                            
948                            /** */
949                            CAPABILITY_PUBLIC_CONTACT(14);
950                            
951                            private static final Map<Integer,CAPABILITY> lookup = new HashMap<Integer,CAPABILITY>();
952                            
953                            static {
954                                    for(CAPABILITY s : EnumSet.allOf(CAPABILITY.class))
955                                            lookup.put(s.getId(), s);
956                            }
957                            
958                            private final int id;
959                            
960                            private CAPABILITY(int value) {
961                                    this.id = value;
962                            }
963                            
964                            public int getId() { return id; }
965                            
966                            public static CAPABILITY get(int code) {
967                                    return lookup.get(code);
968                            }
969                            
970                            public static CAPABILITY fromString(String s) {
971                                    for (CAPABILITY p : lookup.values()) {
972                                            if (p.toString() == s) {
973                                                    return p;
974                                            }
975                                    }
976                                    return null;
977                            }
978                    }
979                    
980                    /**
981                    List of possible states of each of the Contact class CAPABILITY items. <br> */
982                    public enum CAPABILITYSTATUS {
983                    
984                            /** Contact does not have the capability <br>*/
985                            NO_CAPABILITY(0),
986                            
987                            /** Contact has occasionally logged in with Skype client that supports the capability. For example, a contact may have Skype client on several machines, only some of which have webcam - in which case CAPABILITY_VIDEO would have its value set as CAPABILITY_MIXED. <br>*/
988                            CAPABILITY_MIXED(1),
989                            
990                            /** Contact has the capability <br>*/
991                            CAPABILITY_EXISTS(2);
992                            
993                            private static final Map<Integer,CAPABILITYSTATUS> lookup = new HashMap<Integer,CAPABILITYSTATUS>();
994                            
995                            static {
996                                    for(CAPABILITYSTATUS s : EnumSet.allOf(CAPABILITYSTATUS.class))
997                                            lookup.put(s.getId(), s);
998                            }
999                            
1000                            private final int id;
1001                            
1002                            private CAPABILITYSTATUS(int value) {
1003                                    this.id = value;
1004                            }
1005                            
1006                            public int getId() { return id; }
1007                            
1008                            public static CAPABILITYSTATUS get(int code) {
1009                                    return lookup.get(code);
1010                            }
1011                            
1012                            public static CAPABILITYSTATUS fromString(String s) {
1013                                    for (CAPABILITYSTATUS p : lookup.values()) {
1014                                            if (p.toString() == s) {
1015                                                    return p;
1016                                            }
1017                                    }
1018                                    return null;
1019                            }
1020                    }
1021                    
1022                    /**
1023                     *Retrieves a Contact.Capability value. Sets P_REFRESHING to true while querying from server. This method is functionally the same as Contact.GetCapabilityStatus except that it returns a bool value rather than Contact.CAPABILITYSTATUS <br>
1024                     * @param capability The target capability <br>
1025                     * @param queryServer <br> - true: obtains the data from the p2p network/server, and sets P_REFRESHING to true for the duration  <br> - false: obtains the data from the local client <br>
1026                     * @return result <br> - true: the Contact has the target capability through at least one of the Skype clients they have logged into. Corresponds to CAPABILITY_MIXED and CAPABILITY_EXISTS <br> - false: the Contact does not have the target capability. Corresponds to NO_CAPABILITY <br>
1027                     */
1028                    public boolean HasCapability( CAPABILITY capability, boolean queryServer) {
1029                    
1030                            Request request = null;
1031                            try {
1032                                    request = new XCallRequest(2,18);
1033                            } catch (IOException e) {
1034                                    e.printStackTrace();
1035                                    if (skype.errorListener != null)
1036                                            skype.errorListener.OnSkypeKitFatalError();
1037                            }
1038                            request.addParm('O',0,mObjectId);
1039                            request.addParm('e',1,capability.getId());
1040                            request.addParm('b',2,queryServer);
1041                            
1042                            Response r = skype.XCall((XCallRequest)request);
1043                            
1044                            if (r.isErrCall())
1045                                    return false;
1046                                    
1047                            boolean result = false;
1048                            result = r.GetAsBoolean(1);
1049                            return result;
1050                    }
1051                    
1052                    /**
1053                     *Retrieves a Contact.Capability value. Sets P_REFRESHING to true while querying from server. <br>
1054                     * @param capability The target capability, see Contact.Capability enumerator. <br>
1055                     * @param queryServer <br> - true: obtains the data from the p2p network/server, and sets P_REFRESHING to true for the duration  <br> - false: obtains the data from the local client <br>
1056                     * @return status Status of the target capability. <br>
1057                     */
1058                    public CAPABILITYSTATUS GetCapabilityStatus( CAPABILITY capability, boolean queryServer) {
1059                    
1060                            Request request = null;
1061                            try {
1062                                    request = new XCallRequest(2,19);
1063                            } catch (IOException e) {
1064                                    e.printStackTrace();
1065                                    if (skype.errorListener != null)
1066                                            skype.errorListener.OnSkypeKitFatalError();
1067                            }
1068                            request.addParm('O',0,mObjectId);
1069                            request.addParm('e',1,capability.getId());
1070                            request.addParm('b',2,queryServer);
1071                            
1072                            Response r = skype.XCall((XCallRequest)request);
1073                            
1074                            if (r.isErrCall())
1075                                    return null;
1076                                    
1077                            CAPABILITYSTATUS capabilitystatus = null;
1078                            capabilitystatus = CAPABILITYSTATUS.get(r.GetAsInt(1));
1079                            return capabilitystatus;
1080                    }
1081                    
1082                    /**
1083                     *Refreshes all properties, capabilities, and statuses associated with this Contact from p2p/CBL, and sets P_REFRESHING to true for the duration. <br>
1084                     */
1085                    public void RefreshProfile() {
1086                    
1087                            Request request = null;
1088                            try {
1089                                    request = new XCallRequest(2,20);
1090                            } catch (IOException e) {
1091                                    e.printStackTrace();
1092                                    if (skype.errorListener != null)
1093                                            skype.errorListener.OnSkypeKitFatalError();
1094                            }
1095                            request.addParm('O',0,mObjectId);
1096                            
1097                            skype.XCall((XCallRequest)request);
1098                    }
1099                    
1100            
1101            }