001 package com.skype.api;
002
003 import java.io.IOException;
004 import java.util.Collections;
005 import java.util.EnumSet;
006 import java.util.HashMap;
007 import java.util.Iterator;
008 import java.util.Map;
009 import java.util.Vector;
010
011 import com.skype.api.Account.AccountListener;
012 import com.skype.api.Contact.ContactListener;
013 import com.skype.api.ContactGroup.ContactGroupListener;
014 import com.skype.api.ContactSearch.ContactSearchListener;
015 import com.skype.api.Conversation.ConversationListener;
016 import com.skype.api.Message.MessageListener;
017 import com.skype.api.Participant.DTMF;
018 import com.skype.api.Participant.ParticipantListener;
019 import com.skype.api.Sms.SmsListener;
020 import com.skype.api.Transfer.TransferListener;
021 import com.skype.api.Video.VideoListener;
022 import com.skype.api.Voicemail.VoicemailListener;
023 import com.skype.ipc.AbstractDecoder;
024 import com.skype.ipc.Event;
025 import com.skype.ipc.PropertyChange;
026 import com.skype.ipc.Request;
027 import com.skype.ipc.Response;
028 import com.skype.ipc.RootObject;
029 import com.skype.ipc.XCallRequest;
030
031 public class Skype extends RootObject {
032
033
034 public interface SkypeListener {
035 public void OnNewCustomContactGroup(ContactGroup group);
036
037 /**This contact has appeared online. display alert*/
038 public void OnContactOnlineAppearance(Contact contact);
039
040 /**This contact has gone offline. display alert*/
041 public void OnContactGoneOffline(Contact contact);
042
043 /**This event gets fired when a Conversation item is added or removed from the list specified in the type argument. The primary use of this event is to detect creation of new Conversation objects. It can also be used for detecting occurance of live sessions - by monitoring added = true in Conversation.LIVE_CONVERSATIONS. Note that this method is not entirely sufficient for detecting live session termination (added = false and type = Conversation.LIVE_CONVERSATIONS). When the live session goes down, the default behaviour is that the Conversation object remains in the LIVE_CONVERSATIONS list for approximately 10 seconds. When another live session comes up within the same Conversation, the OnConversationListChange event will not fire - because the conversation was already in that list. There are two ways of getting around that. Firstly you can have all the conversations referenced at all times and then monitor Conversation.P_LOCAL_LIVESTATUS property changes, in which case you can pick up incoming live sessions from there. Alternatively, you can remove the delay between live session termination and conversation's removal from the LIVE_CONVERSATIONS list. This delay is controlled by the SETUPKEY_RECENTLY_LIVE_TIMEOUT setup key. To remove the delay, use Skype.SetInt(SETUPKEY_RECENTLY_LIVE_TIMEOUT, 0). Note that this setup key is account-based. You will need to have an account logged in in order to modify its value. <br>*/
044 public void OnConversationListChange(Conversation conversation, Conversation.LIST_TYPE type, boolean added);
045
046 public void OnMessage(Message message, boolean changesInboxTimestamp, Message supersedesHistoryMessage, Conversation conversation);
047
048 /**This callback gets fired when there are changes in the system video device list (USB webcam gets plugged in or is detached.) <br>*/
049 public void OnAvailableVideoDeviceListChange();
050
051 /**This callback gets fired when there are changes in the system audio device list (USB headset gets plugged in or is detached.) <br>*/
052 public void OnAvailableDeviceListChange();
053
054 /**This callback gets fired when the audio strength changes in either playback or recording audio streams. Useful for providing visual indicators of audio activity in your UI. <br>*/
055 public void OnNrgLevelsChange();
056
057 public void OnProxyAuthFailure(PROXYTYPE type);
058
059 }
060
061 public HashMap<Integer, SkypeObject> object_list_base;
062 public HashMap<Integer, Object> listeners_base;
063 public Map<Integer, SkypeObject> object_list;
064 public Map<Integer, Object> listeners;
065
066 private Skype skype;
067
068 public Skype() {
069 object_list_base = new HashMap<Integer, SkypeObject>();
070 listeners_base = new HashMap<Integer, Object>();
071
072 object_list = Collections.synchronizedMap(object_list_base);
073 listeners = Collections.synchronizedMap(listeners_base);
074 skype = this;
075 }
076
077 private static final int module_id = 0;
078
079 public static final int getmoduleid() {
080 return module_id;
081 }
082
083 /** Register listener interface, need to pass module id as first param*/
084 public void RegisterListener(int modid, Object listener)
085 {
086 listeners.put(modid, listener);
087 }
088
089 /** Remove listener interface, need to pass module id as first param*/
090 public void UnRegisterListener(int modid, Object listener)
091 {
092 if (listeners.containsKey(modid))
093 listeners.remove(modid);
094 }
095
096 public void HandlePropertyChange(PropertyChange pc){
097 SkypeObject obj = null;
098 Object val = null;
099 Object prop = null;
100
101 //check object exists in list and get value
102 if (object_list.containsKey(pc.oid))
103 {
104 obj = object_list.get(pc.oid);
105 int kind = pc.GetKind();
106
107 switch (kind) {
108 case 'i':
109 case 'u':
110 case 'e':
111 try {
112 val = new Integer(pc.GetAsInt());
113 } catch (IOException e) {
114 e.printStackTrace();
115 if (errorListener!=null)
116 errorListener.OnSkypeKitFatalError();
117 }
118 break;
119 case 'T':
120 case 'F':
121 try {
122 val = new Boolean(pc.GetAsBoolean());
123 } catch (IOException e) {
124 e.printStackTrace();
125 if (errorListener!=null)
126 errorListener.OnSkypeKitFatalError();
127 }
128 break;
129 case 'S':
130 case 'X':
131 case 'f':
132 try {
133 val = new String(pc.GetAsString());
134 } catch (IOException e) {
135 e.printStackTrace();
136 if (errorListener!=null)
137 errorListener.OnSkypeKitFatalError();
138 }
139 break;
140 case 'B':
141 if (pc.hasValue()){
142 try {
143 val = new String(pc.GetAsBinary(0));
144 } catch (IOException e) {
145 e.printStackTrace();
146 if (errorListener!=null)
147 errorListener.OnSkypeKitFatalError();
148 }
149 }
150 break;
151 default:
152 break;
153 }
154
155 //update the property cache
156 if (val!=null) {
157 obj.mPropCache.put(pc.propid, val);
158 }
159 else {
160 obj.mPropCache.remove(pc.propid);
161 }
162 //call listener if this exists?
163 if (listeners.containsKey(pc.moid))
164 {
165 Object listener = listeners.get(pc.moid);
166 if (listener != null){
167 prop = obj.GetPropertyAsEnum(pc.propid);
168
169 switch (pc.moid)
170 {
171 case 5: //Account
172 ((AccountListener) listener).OnPropertyChange(obj, (Account.PROPERTY)prop, val);
173 break;
174
175 case 2: //Contact
176 ((ContactListener) listener).OnPropertyChange(obj, (Contact.PROPERTY)prop, val);
177 break;
178
179 case 10: //ContactGroup
180 ((ContactGroupListener) listener).OnPropertyChange(obj, (ContactGroup.PROPERTY)prop, val);
181 break;
182
183 case 1: //ContactSearch
184 ((ContactSearchListener) listener).OnPropertyChange(obj, (ContactSearch.PROPERTY)prop, val);
185 break;
186
187 case 18: //Conversation
188 ((ConversationListener) listener).OnPropertyChange(obj, (Conversation.PROPERTY)prop, val);
189 break;
190
191 case 9: //Message
192 ((MessageListener) listener).OnPropertyChange(obj, (Message.PROPERTY)prop, val);
193 break;
194
195 case 19: //Participant
196 ((ParticipantListener) listener).OnPropertyChange(obj, (Participant.PROPERTY)prop, val);
197 break;
198
199 case 12: //Sms
200 ((SmsListener) listener).OnPropertyChange(obj, (Sms.PROPERTY)prop, val);
201 break;
202
203 case 6: //Transfer
204 ((TransferListener) listener).OnPropertyChange(obj, (Transfer.PROPERTY)prop, val);
205 break;
206
207 case 11: //Video
208 ((VideoListener) listener).OnPropertyChange(obj, (Video.PROPERTY)prop, val);
209 break;
210
211 case 7: //Voicemail
212 ((VoicemailListener) listener).OnPropertyChange(obj, (Voicemail.PROPERTY)prop, val);
213 break;
214
215 default:
216 break;
217 }
218 }
219 }
220 }
221 }
222
223 @Override
224 public void Close() throws IOException {
225 FlushObjects();
226 super.Close();
227 }
228
229 /**Clear all Skypekit Objects and PROPERTIES in object cache */
230 public void FlushObjects()
231 {
232 Iterator<Integer> iter = object_list.keySet().iterator();
233 while (iter.hasNext()) {
234 Integer key = iter.next();
235 SkypeObject obj = object_list.get(key);
236 obj.flush_cache();
237 }
238 object_list.clear();
239 }
240
241 /** Mobile Mode related keys for Skypekit runtime*/
242 private static final String mobileModeEnabled = "*Lib/PM/MobileModeEnabled";
243 private static final String superNodeKeepalivePeriod = "*Lib/Connection/SupernodeKeepalivePeriod";
244 private static final String statsUpdatePeriod = "*Lib/Connection/StatsUpdatePeriod";
245
246 private static final String IgnoreReadChatMsg = "*Lib/Chat/IgnoreReadChatMsg";
247
248 /** Turn on Mobile Optimisations in Skypekit runtime and configure Skypekit not to send already read messages*/
249 public void SetMobileMode () {
250 SetInt(mobileModeEnabled, 1);
251 SetInt(superNodeKeepalivePeriod, 600);
252 SetInt(statsUpdatePeriod, 600);
253 SetInt(IgnoreReadChatMsg, 1);}
254
255 /**Static method to retrieve Voicemail object from object id*/
256 public Voicemail GetVoiceMailFromId(int oid, Skype skype)
257 {
258 Voicemail vm = null;
259 if (skype.object_list.containsKey(oid))
260 {
261 vm = (Voicemail) skype.object_list.get(oid);
262 }
263 else
264 {
265 vm = new Voicemail(oid,skype);
266 }
267 return vm;
268 }
269
270
271 @Override
272 public void HandleEvent(Event e) {
273
274 HandleEvent_inner(e);
275
276 }
277 public void HandleEvent_inner(Event e) {
278 if (listeners.containsKey(e.getModuleId())) {
279
280 switch (e.getModuleId()) {
281 case 0: // Skype Listener Events
282 SkypeListener skypelistener = (SkypeListener) listeners.get(e.getModuleId());
283 if (skypelistener != null) {
284
285 switch (e.getEventId()) {
286 case 1: // OnNewCustomContactGroup
287 int group01_oid = 0;
288 ContactGroup group01 = null;
289 group01_oid = e.GetOid(1);
290 if (group01_oid != AbstractDecoder.NULL_VALUE) {
291 group01 = (ContactGroup)skype.factory(ContactGroup.moduleID(), group01_oid, skype);
292 }
293 skypelistener.OnNewCustomContactGroup(group01);
294 break;
295
296 case 2: // OnContactOnlineAppearance
297 int contact02_oid = 0;
298 Contact contact02 = null;
299 contact02_oid = e.GetOid(1);
300 if (contact02_oid != AbstractDecoder.NULL_VALUE) {
301 contact02 = (Contact)skype.factory(Contact.moduleID(), contact02_oid, skype);
302 }
303 skypelistener.OnContactOnlineAppearance(contact02);
304 break;
305
306 case 3: // OnContactGoneOffline
307 int contact03_oid = 0;
308 Contact contact03 = null;
309 contact03_oid = e.GetOid(1);
310 if (contact03_oid != AbstractDecoder.NULL_VALUE) {
311 contact03 = (Contact)skype.factory(Contact.moduleID(), contact03_oid, skype);
312 }
313 skypelistener.OnContactGoneOffline(contact03);
314 break;
315
316 case 4: // OnConversationListChange
317 int conversation04_oid = 0;
318 Conversation conversation04 = null;
319 conversation04_oid = e.GetOid(1);
320 if (conversation04_oid != AbstractDecoder.NULL_VALUE) {
321 conversation04 = (Conversation)skype.factory(Conversation.moduleID(), conversation04_oid, skype);
322 }
323 Conversation.LIST_TYPE type04 = null;
324 type04 = Conversation.LIST_TYPE.get(e.GetAsInt(2));
325 boolean added04 = false;
326 added04 = e.GetAsBoolean(3);
327 skypelistener.OnConversationListChange(conversation04, type04, added04);
328 break;
329
330 case 5: // OnMessage
331 int message05_oid = 0;
332 Message message05 = null;
333 message05_oid = e.GetOid(1);
334 if (message05_oid != AbstractDecoder.NULL_VALUE) {
335 message05 = (Message)skype.factory(Message.moduleID(), message05_oid, skype);
336 }
337 boolean changesInboxTimestamp05 = false;
338 changesInboxTimestamp05 = e.GetAsBoolean(2);
339 int supersedesHistoryMessage05_oid = 0;
340 Message supersedesHistoryMessage05 = null;
341 supersedesHistoryMessage05_oid = e.GetOid(3);
342 if (supersedesHistoryMessage05_oid != AbstractDecoder.NULL_VALUE) {
343 supersedesHistoryMessage05 = (Message)skype.factory(Message.moduleID(), supersedesHistoryMessage05_oid, skype);
344 }
345 int conversation05_oid = 0;
346 Conversation conversation05 = null;
347 conversation05_oid = e.GetOid(4);
348 if (conversation05_oid != AbstractDecoder.NULL_VALUE) {
349 conversation05 = (Conversation)skype.factory(Conversation.moduleID(), conversation05_oid, skype);
350 }
351 skypelistener.OnMessage(message05, changesInboxTimestamp05, supersedesHistoryMessage05, conversation05);
352 ConversationListener cl = (ConversationListener)listeners.get(18);
353 if (cl != null) {
354 cl.OnMessage(conversation05, message05);
355 };
356 break;
357
358 case 7: // OnAvailableVideoDeviceListChange
359 skypelistener.OnAvailableVideoDeviceListChange();
360 break;
361
362 case 10: // OnAvailableDeviceListChange
363 skypelistener.OnAvailableDeviceListChange();
364 break;
365
366 case 11: // OnNrgLevelsChange
367 skypelistener.OnNrgLevelsChange();
368 break;
369
370 case 12: // OnProxyAuthFailure
371 PROXYTYPE type012 = null;
372 type012 = PROXYTYPE.get(e.GetAsInt(1));
373 skypelistener.OnProxyAuthFailure(type012);
374 break;
375
376 default:
377 break;
378
379 }
380 }
381 break;
382
383 case 10: // Module ContactGroup
384 ContactGroupListener contactgrouplistener = (ContactGroupListener)listeners.get(e.getModuleId());
385 if (contactgrouplistener != null) {
386 int contactgroup_oid = e.GetOid(0);
387 SkypeObject obj = skype.factory(e.getModuleId(), contactgroup_oid, skype);
388
389 switch (e.getEventId()){
390 case 1: // Event OnChangeConversation
391 int conversation101_oid = 0;
392 Conversation conversation101 = null;
393 conversation101_oid = e.GetOid(1);
394 if (conversation101_oid != AbstractDecoder.NULL_VALUE) {
395 conversation101 = (Conversation)skype.factory(Conversation.moduleID(), conversation101_oid, skype);
396 }
397 contactgrouplistener.OnChangeConversation(obj, conversation101);
398 break;
399
400 case 2: // Event OnChange
401 int contact102_oid = 0;
402 Contact contact102 = null;
403 contact102_oid = e.GetOid(1);
404 if (contact102_oid != AbstractDecoder.NULL_VALUE) {
405 contact102 = (Contact)skype.factory(Contact.moduleID(), contact102_oid, skype);
406 }
407 contactgrouplistener.OnChange(obj, contact102);
408 break;
409
410 default:
411 break;
412
413 }
414 }
415 break;
416
417 case 1: // Module ContactSearch
418 ContactSearchListener contactsearchlistener = (ContactSearchListener)listeners.get(e.getModuleId());
419 if (contactsearchlistener != null) {
420 int contactsearch_oid = e.GetOid(0);
421 SkypeObject obj = skype.factory(e.getModuleId(), contactsearch_oid, skype);
422
423 switch (e.getEventId()){
424 case 1: // Event OnNewResult
425 int contact11_oid = 0;
426 Contact contact11 = null;
427 contact11_oid = e.GetOid(1);
428 if (contact11_oid != AbstractDecoder.NULL_VALUE) {
429 contact11 = (Contact)skype.factory(Contact.moduleID(), contact11_oid, skype);
430 }
431 int rankValue11 = 0;
432 rankValue11 = e.GetAsInt(2);
433 contactsearchlistener.OnNewResult(obj, contact11, rankValue11);
434 break;
435
436 default:
437 break;
438
439 }
440 }
441 break;
442
443 case 19: // Module Participant
444 ParticipantListener participantlistener = (ParticipantListener)listeners.get(e.getModuleId());
445 if (participantlistener != null) {
446 int participant_oid = e.GetOid(0);
447 SkypeObject obj = skype.factory(e.getModuleId(), participant_oid, skype);
448
449 switch (e.getEventId()){
450 case 1: // Event OnIncomingDTMF
451 DTMF dtmf191 = null;
452 dtmf191 = DTMF.get(e.GetAsInt(1));
453 participantlistener.OnIncomingDTMF(obj, dtmf191);
454 break;
455
456 default:
457 break;
458
459 }
460 }
461 break;
462
463 case 18: // Module Conversation
464 ConversationListener conversationlistener = (ConversationListener)listeners.get(e.getModuleId());
465 if (conversationlistener != null) {
466 int conversation_oid = e.GetOid(0);
467 SkypeObject obj = skype.factory(e.getModuleId(), conversation_oid, skype);
468
469 switch (e.getEventId()){
470 case 1: // Event OnParticipantListChange
471 conversationlistener.OnParticipantListChange(obj);
472 break;
473
474 case 2: // Event OnMessage
475 int message182_oid = 0;
476 Message message182 = null;
477 message182_oid = e.GetOid(1);
478 if (message182_oid != AbstractDecoder.NULL_VALUE) {
479 message182 = (Message)skype.factory(Message.moduleID(), message182_oid, skype);
480 }
481 conversationlistener.OnMessage(obj, message182);
482 break;
483
484 case 3: // Event OnSpawnConference
485 int spawned183_oid = 0;
486 Conversation spawned183 = null;
487 spawned183_oid = e.GetOid(1);
488 if (spawned183_oid != AbstractDecoder.NULL_VALUE) {
489 spawned183 = (Conversation)skype.factory(Conversation.moduleID(), spawned183_oid, skype);
490 }
491 conversationlistener.OnSpawnConference(obj, spawned183);
492 break;
493
494 default:
495 break;
496
497 }
498 }
499 break;
500
501 case 11: // Module Video
502 VideoListener videolistener = (VideoListener)listeners.get(e.getModuleId());
503 if (videolistener != null) {
504 int video_oid = e.GetOid(0);
505 SkypeObject obj = skype.factory(e.getModuleId(), video_oid, skype);
506
507 switch (e.getEventId()){
508 case 2: // Event OnCaptureRequestCompleted
509 int requestId112 = 0;
510 requestId112 = e.GetAsInt(1);
511 boolean isSuccessful112 = false;
512 isSuccessful112 = e.GetAsBoolean(2);
513 byte[] image112 = null;
514 image112 = e.GetAsBinary(3);
515 int width112 = 0;
516 width112 = e.GetAsInt(4);
517 int height112 = 0;
518 height112 = e.GetAsInt(5);
519 videolistener.OnCaptureRequestCompleted(obj, requestId112, isSuccessful112, image112, width112, height112);
520 break;
521
522 case 1: // Event OnLastFrameCapture
523 byte[] image111 = null;
524 image111 = e.GetAsBinary(1);
525 int width111 = 0;
526 width111 = e.GetAsInt(2);
527 int height111 = 0;
528 height111 = e.GetAsInt(3);
529 videolistener.OnLastFrameCapture(obj, image111, width111, height111);
530 break;
531
532 default:
533 break;
534
535 }
536 }
537 break;
538
539 default:
540 break;
541
542 }
543 }
544 }
545
546 /**
547 * @return started
548 */
549 public boolean Start() {
550
551 Request request = null;
552 try {
553 request = new XCallRequest(0,145);
554 } catch (IOException e) {
555 e.printStackTrace();
556 if (errorListener != null)
557 errorListener.OnSkypeKitFatalError();
558 }
559
560 Response r = XCall((XCallRequest)request);
561
562 if (r.isErrCall())
563 return false;
564
565 boolean started = false;
566 started = r.GetAsBoolean(1);
567 return started;
568 }
569
570 /** Setupkey SETUPKEY_DB_STORAGE_QUOTA_KB type:int default value:"0" <br>Use this key to limit the size of the main.db file. Value is in KB. Quota are disabled by default. <br>This setup key is machine-specific and affects all local accounts. <br> */
571 public static final String DB_STORAGE_QUOTA_KB = "*Lib/DbManager/StorageQuotaKb";
572
573 /**
574 *returns the runtime version as a string
575 * @return version
576 */
577 public String GetVersionString() {
578
579 Request request = null;
580 try {
581 request = new XCallRequest(0,28);
582 } catch (IOException e) {
583 e.printStackTrace();
584 if (errorListener != null)
585 errorListener.OnSkypeKitFatalError();
586 }
587
588 Response r = XCall((XCallRequest)request);
589
590 if (r.isErrCall())
591 return null;
592
593 String version = null;
594 version = r.GetAsString(1);
595 return version;
596 }
597
598 /**
599 *Takes TYPE argument (TYPE comes from ContactGroup class) and returns reference to the corresponding hardwired contact group. For example (C++): skype->GetHardwiredContactGroup(ContactGroup.ONLINE_BUDDIES, GroupRef) would return the list of all contacts that are currently online. <br>
600 * @param type
601 * @return contactGroup
602 */
603 public ContactGroup GetHardwiredContactGroup( ContactGroup.TYPE type) {
604
605 Request request = null;
606 try {
607 request = new XCallRequest(0,1);
608 } catch (IOException e) {
609 e.printStackTrace();
610 if (errorListener != null)
611 errorListener.OnSkypeKitFatalError();
612 }
613 request.addParm('e',1,type.getId());
614
615 Response r = XCall((XCallRequest)request);
616
617 if (r.isErrCall())
618 return null;
619
620 int oid = 0;
621 ContactGroup contactGroup = null;
622 oid = r.GetOid(1);
623 if (oid != AbstractDecoder.NULL_VALUE) {
624 contactGroup = (ContactGroup)skype.factory(ContactGroup.moduleID(), oid, skype);
625 }
626 return contactGroup;
627 }
628
629 /**
630 *Returns a list of custom contact group references, i.e. all contact groups that are not hardwired. <br>
631 * @return groups
632 */
633 public ContactGroup [] GetCustomContactGroups() {
634
635 Request request = null;
636 try {
637 request = new XCallRequest(0,2);
638 } catch (IOException e) {
639 e.printStackTrace();
640 if (errorListener != null)
641 errorListener.OnSkypeKitFatalError();
642 }
643
644 Response r = XCall((XCallRequest)request);
645
646 if (r.isErrCall())
647 return null;
648
649 Vector<ContactGroup> groups = new Vector<ContactGroup>();
650 while (r.HasMore(1))
651 {
652 int oid = 0;
653 ContactGroup contactgroup = null;
654 oid = r.GetOid(1);
655 if (oid != AbstractDecoder.NULL_VALUE) {
656 contactgroup = (ContactGroup)skype.factory(ContactGroup.moduleID(), oid, skype);
657 }
658 groups.add(contactgroup);
659 }
660 return groups.toArray(new ContactGroup[groups.size()]);
661
662 }
663
664 /**
665 *Creates a new empty contact group object and returns a reference to it. The group will then show up in the custom group list that you can get with Skype class GetCustomContactGroups method. Existing contacts can be added to the new group with ContactGroup class AddContact method and a custom name can be given to it with GiveDisplayName method. <br>Note that no check is made for existing of displaynames with the same name - if you wish to force uniqueness in custom group names you will have to check that yourself before creating the group. <br>
666 * @return group
667 */
668 public ContactGroup CreateCustomContactGroup() {
669
670 Request request = null;
671 try {
672 request = new XCallRequest(0,3);
673 } catch (IOException e) {
674 e.printStackTrace();
675 if (errorListener != null)
676 errorListener.OnSkypeKitFatalError();
677 }
678
679 Response r = XCall((XCallRequest)request);
680
681 if (r.isErrCall())
682 return null;
683
684 int oid = 0;
685 ContactGroup group = null;
686 oid = r.GetOid(1);
687 if (oid != AbstractDecoder.NULL_VALUE) {
688 group = (ContactGroup)skype.factory(ContactGroup.moduleID(), oid, skype);
689 }
690 return group;
691 }
692
693 /**
694 *analyzes the identity for contact type
695 * @param identity
696 * @return type
697 */
698 public Contact.TYPE GetContactType( String identity) {
699
700 Request request = null;
701 try {
702 request = new XCallRequest(0,5);
703 } catch (IOException e) {
704 e.printStackTrace();
705 if (errorListener != null)
706 errorListener.OnSkypeKitFatalError();
707 }
708 request.addParm('S',1,identity);
709
710 Response r = XCall((XCallRequest)request);
711
712 if (r.isErrCall())
713 return null;
714
715 Contact.TYPE type = null;
716 type = Contact.TYPE.get(r.GetAsInt(1));
717 return type;
718 }
719
720 /**
721 *Returns a Contact object reference. If a matching contact is not found in the existing contact list, a new Contact object will be created. Note that if you pass in a phone number in the identity argument, the type for the newly created Contact will be automatically set to Contact.PSTN (Contact.SKYPE otherwise). <br>
722 * @param identity Either skypename or a phone number <br>
723 * @return contact Returns a contact object. <br>
724 */
725 public Contact GetContact( String identity) {
726
727 Request request = null;
728 try {
729 request = new XCallRequest(0,6);
730 } catch (IOException e) {
731 e.printStackTrace();
732 if (errorListener != null)
733 errorListener.OnSkypeKitFatalError();
734 }
735 request.addParm('S',1,identity);
736
737 Response r = XCall((XCallRequest)request);
738
739 if (r.isErrCall())
740 return null;
741
742 int oid = 0;
743 Contact contact = null;
744 oid = r.GetOid(2);
745 if (oid != AbstractDecoder.NULL_VALUE) {
746 contact = (Contact)skype.factory(Contact.moduleID(), oid, skype);
747 }
748 return contact;
749 }
750
751 /**
752 * @param number
753 * @return FindContactByPstnNumberResult
754 */
755 public FindContactByPstnNumberResult FindContactByPstnNumber( String number) {
756
757 Request request = null;
758 try {
759 request = new XCallRequest(0,8);
760 } catch (IOException e) {
761 e.printStackTrace();
762 if (errorListener != null)
763 errorListener.OnSkypeKitFatalError();
764 }
765 request.addParm('S',1,number);
766
767 Response r = XCall((XCallRequest)request);
768
769 if (r.isErrCall())
770 return null;
771
772 FindContactByPstnNumberResult result = new FindContactByPstnNumberResult();
773
774 boolean found = false;
775 found = r.GetAsBoolean(1);
776 result.found = found;
777
778 int oid = 0;
779 Contact contact = null;
780 oid = r.GetOid(2);
781 if (oid != AbstractDecoder.NULL_VALUE) {
782 contact = (Contact)skype.factory(Contact.moduleID(), oid, skype);
783 }
784 result.contact = contact;
785
786 int foundInKey = 0;
787 foundInKey = r.GetAsInt(3);
788 result.foundInKey = foundInKey;
789
790 return result;
791 }
792
793 public class FindContactByPstnNumberResult {
794 public boolean found;
795 public Contact contact;
796 public int foundInKey; /** type is actually PROPKEY */
797 }
798
799 /**
800 */
801 public enum IDENTITYTYPE {
802
803 /** */
804 UNRECOGNIZED(0),
805
806 /** */
807 SKYPE(1),
808
809 /** */
810 SKYPE_MYSELF(2),
811
812 /** */
813 SKYPE_UNDISCLOSED(3),
814
815 /** */
816 PSTN(4),
817
818 /** */
819 PSTN_EMERGENCY(5),
820
821 /** */
822 PSTN_FREE(6),
823
824 /** */
825 PSTN_UNDISCLOSED(7),
826
827 /** */
828 CONFERENCE(8),
829
830 /** */
831 EXTERNAL(9);
832
833 private static final Map<Integer,IDENTITYTYPE> lookup = new HashMap<Integer,IDENTITYTYPE>();
834
835 static {
836 for(IDENTITYTYPE s : EnumSet.allOf(IDENTITYTYPE.class))
837 lookup.put(s.getId(), s);
838 }
839
840 private final int id;
841
842 private IDENTITYTYPE(int value) {
843 this.id = value;
844 }
845
846 public int getId() { return id; }
847
848 public static IDENTITYTYPE get(int code) {
849 return lookup.get(code);
850 }
851
852 public static IDENTITYTYPE fromString(String s) {
853 for (IDENTITYTYPE p : lookup.values()) {
854 if (p.toString() == s) {
855 return p;
856 }
857 }
858 return null;
859 }
860 }
861
862 /**
863 *This takes skypename or a phone number string as argument and returns corresponding identity type (SKYPE, SKYPE_MYSELF, PSTN, etc.) <br>
864 * @param identity
865 * @return type
866 */
867 public IDENTITYTYPE GetIdentityType( String identity) {
868
869 Request request = null;
870 try {
871 request = new XCallRequest(0,19);
872 } catch (IOException e) {
873 e.printStackTrace();
874 if (errorListener != null)
875 errorListener.OnSkypeKitFatalError();
876 }
877 request.addParm('S',1,identity);
878
879 Response r = XCall((XCallRequest)request);
880
881 if (r.isErrCall())
882 return null;
883
884 IDENTITYTYPE identitytype = null;
885 identitytype = IDENTITYTYPE.get(r.GetAsInt(1));
886 return identitytype;
887 }
888
889 /**
890 */
891 public enum NORMALIZERESULT {
892
893 /** */
894 IDENTITY_OK(0),
895
896 /** */
897 IDENTITY_EMPTY(1),
898
899 /** */
900 IDENTITY_TOO_LONG(2),
901
902 /** */
903 IDENTITY_CONTAINS_INVALID_CHAR(3),
904
905 /** */
906 PSTN_NUMBER_TOO_SHORT(4),
907
908 /** identity looks like pstn number but does not start with +/00/011*/
909 PSTN_NUMBER_HAS_INVALID_PREFIX(5),
910
911 /** */
912 SKYPENAME_STARTS_WITH_NONALPHA(6),
913
914 /** returned only when isNewSkypeName*/
915 SKYPENAME_SHORTER_THAN_6_CHARS(7);
916
917 private static final Map<Integer,NORMALIZERESULT> lookup = new HashMap<Integer,NORMALIZERESULT>();
918
919 static {
920 for(NORMALIZERESULT s : EnumSet.allOf(NORMALIZERESULT.class))
921 lookup.put(s.getId(), s);
922 }
923
924 private final int id;
925
926 private NORMALIZERESULT(int value) {
927 this.id = value;
928 }
929
930 public int getId() { return id; }
931
932 public static NORMALIZERESULT get(int code) {
933 return lookup.get(code);
934 }
935
936 public static NORMALIZERESULT fromString(String s) {
937 for (NORMALIZERESULT p : lookup.values()) {
938 if (p.toString() == s) {
939 return p;
940 }
941 }
942 return null;
943 }
944 }
945
946 /**
947 *compares two identities to see if they match
948 * @param identityA
949 * @param identityB
950 * @return result
951 */
952 public boolean IdentitiesMatch( String identityA, String identityB) {
953
954 Request request = null;
955 try {
956 request = new XCallRequest(0,88);
957 } catch (IOException e) {
958 e.printStackTrace();
959 if (errorListener != null)
960 errorListener.OnSkypeKitFatalError();
961 }
962 request.addParm('S',1,identityA);
963 request.addParm('S',2,identityB);
964
965 Response r = XCall((XCallRequest)request);
966
967 if (r.isErrCall())
968 return false;
969
970 boolean result = false;
971 result = r.GetAsBoolean(1);
972 return result;
973 }
974
975 /**
976 *This method is deprecated. Use ValidateProfileString method instead. <br>
977 * @param original
978 * @param isNewSkypeName
979 * @return NormalizeIdentityResult
980 */
981 public NormalizeIdentityResult NormalizeIdentity( String original, boolean isNewSkypeName) {
982
983 Request request = null;
984 try {
985 request = new XCallRequest(0,9);
986 } catch (IOException e) {
987 e.printStackTrace();
988 if (errorListener != null)
989 errorListener.OnSkypeKitFatalError();
990 }
991 request.addParm('S',1,original);
992 request.addParm('b',2,isNewSkypeName);
993
994 Response r = XCall((XCallRequest)request);
995
996 if (r.isErrCall())
997 return null;
998
999 NormalizeIdentityResult result = new NormalizeIdentityResult();
1000
1001 NORMALIZERESULT normalizeresult = null;
1002 normalizeresult = NORMALIZERESULT.get(r.GetAsInt(1));
1003 result.result = normalizeresult;
1004
1005 String normalized = null;
1006 normalized = r.GetAsString(2);
1007 result.normalized = normalized;
1008
1009 return result;
1010 }
1011
1012 public class NormalizeIdentityResult {
1013 public NORMALIZERESULT result;
1014 public String normalized;
1015 }
1016
1017 /**
1018 *NormalizePSTNWithCountry checks if the phone number starts with + if it doesn't, it prefixes the output with +XXX (where XXX is the country code). It also converts letters to numbers based on the standard phone keypad, so that the phone number string 212CALLME1 with country code 372 (Estonia) would be normalized to +3722122255631. If the method cannot normalize the phone number (because it's too long, too short, etc.), it returns an error code in &result. <br>
1019 * @param original
1020 * @param countryPrefix
1021 * @return NormalizePSTNWithCountryResult
1022 */
1023 public NormalizePSTNWithCountryResult NormalizePSTNWithCountry( String original, int countryPrefix) {
1024
1025 Request request = null;
1026 try {
1027 request = new XCallRequest(0,205);
1028 } catch (IOException e) {
1029 e.printStackTrace();
1030 if (errorListener != null)
1031 errorListener.OnSkypeKitFatalError();
1032 }
1033 request.addParm('S',1,original);
1034 request.addParm('u',2,countryPrefix);
1035
1036 Response r = XCall((XCallRequest)request);
1037
1038 if (r.isErrCall())
1039 return null;
1040
1041 NormalizePSTNWithCountryResult result = new NormalizePSTNWithCountryResult();
1042
1043 NORMALIZERESULT normalizeresult = null;
1044 normalizeresult = NORMALIZERESULT.get(r.GetAsInt(1));
1045 result.result = normalizeresult;
1046
1047 String normalized = null;
1048 normalized = r.GetAsString(2);
1049 result.normalized = normalized;
1050
1051 return result;
1052 }
1053
1054 public class NormalizePSTNWithCountryResult {
1055 public NORMALIZERESULT result;
1056 public String normalized;
1057 }
1058
1059 /**
1060 *list of (min,max) pairs
1061 * @return rangeList
1062 */
1063 public int [] GetOptimalAgeRanges() {
1064
1065 Request request = null;
1066 try {
1067 request = new XCallRequest(0,77);
1068 } catch (IOException e) {
1069 e.printStackTrace();
1070 if (errorListener != null)
1071 errorListener.OnSkypeKitFatalError();
1072 }
1073
1074 Response r = XCall((XCallRequest)request);
1075
1076 if (r.isErrCall())
1077 return null;
1078
1079 Vector<Integer> rangeList = new Vector<Integer>();
1080 while (r.HasMore(1))
1081 {
1082 Integer integer = null;
1083 integer = new Integer(r.GetAsInt(1));
1084 rangeList.add(integer);
1085 }
1086
1087 int[] intArray = new int[rangeList.size()];
1088 for (int i = 0; i < rangeList.size(); i++) {
1089 intArray[i] = rangeList.get(i);
1090 }
1091 return intArray;
1092 }
1093
1094 /**
1095 *Creates a blank contact search object, in which you can add your custom search terms. For more information how asynchronous contact search works, see ContactSearch class details. <br>
1096 * @return search Returns blank ContactSearch object. <br>
1097 */
1098 public ContactSearch CreateContactSearch() {
1099
1100 Request request = null;
1101 try {
1102 request = new XCallRequest(0,10);
1103 } catch (IOException e) {
1104 e.printStackTrace();
1105 if (errorListener != null)
1106 errorListener.OnSkypeKitFatalError();
1107 }
1108
1109 Response r = XCall((XCallRequest)request);
1110
1111 if (r.isErrCall())
1112 return null;
1113
1114 int oid = 0;
1115 ContactSearch search = null;
1116 oid = r.GetOid(1);
1117 if (oid != AbstractDecoder.NULL_VALUE) {
1118 search = (ContactSearch)skype.factory(ContactSearch.moduleID(), oid, skype);
1119 }
1120 return search;
1121 }
1122
1123 /**
1124 *searches skypenames, aliases, fullnames, emails. false if not valid
1125 * @param text
1126 * @return search
1127 */
1128 public ContactSearch CreateBasicContactSearch( String text) {
1129
1130 Request request = null;
1131 try {
1132 request = new XCallRequest(0,11);
1133 } catch (IOException e) {
1134 e.printStackTrace();
1135 if (errorListener != null)
1136 errorListener.OnSkypeKitFatalError();
1137 }
1138 request.addParm('S',1,text);
1139
1140 Response r = XCall((XCallRequest)request);
1141
1142 if (r.isErrCall())
1143 return null;
1144
1145 int oid = 0;
1146 ContactSearch search = null;
1147 oid = r.GetOid(1);
1148 if (oid != AbstractDecoder.NULL_VALUE) {
1149 search = (ContactSearch)skype.factory(ContactSearch.moduleID(), oid, skype);
1150 }
1151 return search;
1152 }
1153
1154 /**
1155 *searches skypenames and aliases. returns 0 or 1 results. false if not valid
1156 * @param identity
1157 * @return search
1158 */
1159 public ContactSearch CreateIdentitySearch( String identity) {
1160
1161 Request request = null;
1162 try {
1163 request = new XCallRequest(0,12);
1164 } catch (IOException e) {
1165 e.printStackTrace();
1166 if (errorListener != null)
1167 errorListener.OnSkypeKitFatalError();
1168 }
1169 request.addParm('S',1,identity);
1170
1171 Response r = XCall((XCallRequest)request);
1172
1173 if (r.isErrCall())
1174 return null;
1175
1176 int oid = 0;
1177 ContactSearch search = null;
1178 oid = r.GetOid(1);
1179 if (oid != AbstractDecoder.NULL_VALUE) {
1180 search = (ContactSearch)skype.factory(ContactSearch.moduleID(), oid, skype);
1181 }
1182 return search;
1183 }
1184
1185 /**
1186 sync failure reasons when starting a transfer */
1187 public enum TRANSFER_SENDFILE_ERROR {
1188
1189 /** */
1190 TRANSFER_OPEN_SUCCESS(0),
1191
1192 /** */
1193 TRANSFER_BAD_FILENAME(1),
1194
1195 /** */
1196 TRANSFER_OPEN_FAILED(2),
1197
1198 /** */
1199 TRANSFER_TOO_MANY_PARALLEL(3);
1200
1201 private static final Map<Integer,TRANSFER_SENDFILE_ERROR> lookup = new HashMap<Integer,TRANSFER_SENDFILE_ERROR>();
1202
1203 static {
1204 for(TRANSFER_SENDFILE_ERROR s : EnumSet.allOf(TRANSFER_SENDFILE_ERROR.class))
1205 lookup.put(s.getId(), s);
1206 }
1207
1208 private final int id;
1209
1210 private TRANSFER_SENDFILE_ERROR(int value) {
1211 this.id = value;
1212 }
1213
1214 public int getId() { return id; }
1215
1216 public static TRANSFER_SENDFILE_ERROR get(int code) {
1217 return lookup.get(code);
1218 }
1219
1220 public static TRANSFER_SENDFILE_ERROR fromString(String s) {
1221 for (TRANSFER_SENDFILE_ERROR p : lookup.values()) {
1222 if (p.toString() == s) {
1223 return p;
1224 }
1225 }
1226 return null;
1227 }
1228 }
1229
1230 /**
1231 *Creates a new empty conversation object and returns a reference to it. <br>
1232 * @return conference
1233 */
1234 public Conversation CreateConference() {
1235
1236 Request request = null;
1237 try {
1238 request = new XCallRequest(0,13);
1239 } catch (IOException e) {
1240 e.printStackTrace();
1241 if (errorListener != null)
1242 errorListener.OnSkypeKitFatalError();
1243 }
1244
1245 Response r = XCall((XCallRequest)request);
1246
1247 if (r.isErrCall())
1248 return null;
1249
1250 int oid = 0;
1251 Conversation conference = null;
1252 oid = r.GetOid(1);
1253 if (oid != AbstractDecoder.NULL_VALUE) {
1254 conference = (Conversation)skype.factory(Conversation.moduleID(), oid, skype);
1255 }
1256 return conference;
1257 }
1258
1259 /**
1260 *Returns reference tp conversation object by conversation ID string (equivalent of old chat ID). NB! ID here is that of conversation, rather than skypename of dialog partner. If you want to retrieve a conversation object with any particular person, then Skype class GetConversationByParticipants method is what you are looking for. <br>
1261 * @param convoIdentity
1262 * @return conversation
1263 */
1264 public Conversation GetConversationByIdentity( String convoIdentity) {
1265
1266 Request request = null;
1267 try {
1268 request = new XCallRequest(0,15);
1269 } catch (IOException e) {
1270 e.printStackTrace();
1271 if (errorListener != null)
1272 errorListener.OnSkypeKitFatalError();
1273 }
1274 request.addParm('S',1,convoIdentity);
1275
1276 Response r = XCall((XCallRequest)request);
1277
1278 if (r.isErrCall())
1279 return null;
1280
1281 int oid = 0;
1282 Conversation conversation = null;
1283 oid = r.GetOid(1);
1284 if (oid != AbstractDecoder.NULL_VALUE) {
1285 conversation = (Conversation)skype.factory(Conversation.moduleID(), oid, skype);
1286 }
1287 return conversation;
1288 }
1289
1290 /**
1291 *myself not included
1292 * @param participantIdentities
1293 * @param createIfNonExisting
1294 * @param ignoreBookmarkedOrNamed
1295 * @return conversation
1296 */
1297 public Conversation GetConversationByParticipants( String [] participantIdentities, boolean createIfNonExisting, boolean ignoreBookmarkedOrNamed) {
1298
1299 Request request = null;
1300 try {
1301 request = new XCallRequest(0,16);
1302 } catch (IOException e) {
1303 e.printStackTrace();
1304 if (errorListener != null)
1305 errorListener.OnSkypeKitFatalError();
1306 }
1307 request.addListStart(1);
1308 for (int i=0;i<participantIdentities.length;i++) {
1309 request.addParm('S',participantIdentities[i]);
1310 }
1311 request.addParm('b',2,createIfNonExisting);
1312 request.addParm('b',3,ignoreBookmarkedOrNamed);
1313
1314 Response r = XCall((XCallRequest)request);
1315
1316 if (r.isErrCall())
1317 return null;
1318
1319 int oid = 0;
1320 Conversation conversation = null;
1321 oid = r.GetOid(1);
1322 if (oid != AbstractDecoder.NULL_VALUE) {
1323 conversation = (Conversation)skype.factory(Conversation.moduleID(), oid, skype);
1324 }
1325 return conversation;
1326 }
1327
1328 /**
1329 *Retrieves a Conversation object by Public Conversation BLOB. Public conversation blobs are globally unique conversation IDs that provide a method for joining conversation without explicitly being added to the conversation by someone already in it. Programmatically, a Conversation BLOB can be retrieved with Conversation.GetJoinBlob method. In Skype desktop clients, the BLOB can be retrieved by typing "/get uri" in a conversation. The conversation can then be joined by people who have somehow received that BLOB. <br>
1330 * @param joinBlob The BLOB string. <br>
1331 * @param alsoJoin If set to true, automatically joins current user into the Conversation. <br>
1332 * @return conversation Returns Conversation object if successful. <br>
1333 */
1334 public Conversation GetConversationByBlob( String joinBlob, boolean alsoJoin) {
1335
1336 Request request = null;
1337 try {
1338 request = new XCallRequest(0,17);
1339 } catch (IOException e) {
1340 e.printStackTrace();
1341 if (errorListener != null)
1342 errorListener.OnSkypeKitFatalError();
1343 }
1344 request.addParm('S',1,joinBlob);
1345 request.addParm('b',2,alsoJoin);
1346
1347 Response r = XCall((XCallRequest)request);
1348
1349 if (r.isErrCall())
1350 return null;
1351
1352 int oid = 0;
1353 Conversation conversation = null;
1354 oid = r.GetOid(1);
1355 if (oid != AbstractDecoder.NULL_VALUE) {
1356 conversation = (Conversation)skype.factory(Conversation.moduleID(), oid, skype);
1357 }
1358 return conversation;
1359 }
1360
1361 /**
1362 *Returns a list of Conversation objects by Conversation.LIST_TYPE filter. <br>
1363 * @param type Filter. <br>
1364 * @return conversations List of conversations matching the filter. <br>
1365 */
1366 public Conversation [] GetConversationList( Conversation.LIST_TYPE type) {
1367
1368 Request request = null;
1369 try {
1370 request = new XCallRequest(0,18);
1371 } catch (IOException e) {
1372 e.printStackTrace();
1373 if (errorListener != null)
1374 errorListener.OnSkypeKitFatalError();
1375 }
1376 request.addParm('e',1,type.getId());
1377
1378 Response r = XCall((XCallRequest)request);
1379
1380 if (r.isErrCall())
1381 return null;
1382
1383 Vector<Conversation> conversations = new Vector<Conversation>();
1384 while (r.HasMore(1))
1385 {
1386 int oid = 0;
1387 Conversation conversation = null;
1388 oid = r.GetOid(1);
1389 if (oid != AbstractDecoder.NULL_VALUE) {
1390 conversation = (Conversation)skype.factory(Conversation.moduleID(), oid, skype);
1391 }
1392 conversations.add(conversation);
1393 }
1394 return conversations.toArray(new Conversation[conversations.size()]);
1395
1396 }
1397
1398 /**
1399 *Retrieves a Message object by the P_GUID property (globally unique ID, same for all the participants of the conversation, in which this message occured). <br>
1400 * @param guid Globally unique ID of the message. <br>
1401 * @return message Returns a Message object if a match was found. <br>
1402 */
1403 public Message GetMessageByGuid( byte[] guid) {
1404
1405 Request request = null;
1406 try {
1407 request = new XCallRequest(0,21);
1408 } catch (IOException e) {
1409 e.printStackTrace();
1410 if (errorListener != null)
1411 errorListener.OnSkypeKitFatalError();
1412 }
1413 request.addParm('B',1,guid);
1414
1415 Response r = XCall((XCallRequest)request);
1416
1417 if (r.isErrCall())
1418 return null;
1419
1420 int oid = 0;
1421 Message message = null;
1422 oid = r.GetOid(1);
1423 if (oid != AbstractDecoder.NULL_VALUE) {
1424 message = (Message)skype.factory(Message.moduleID(), oid, skype);
1425 }
1426 return message;
1427 }
1428
1429 /**
1430 *Returns all messages of the given type, the most recent POSTED_EMOTE or POSTED_TEXT of each conversation.
1431 * @param type Type of messages requested
1432 * @param latestPerConvOnly Whether to return only the most recent message per conversation
1433 * @param fromTimestampInc Starting timestamp for reqested range, inclusive
1434 * @param toTimestampExc Ending timestamp for requested range, exclusive
1435 * @return messages
1436 */
1437 public Message [] GetMessageListByType( Message.TYPE type, boolean latestPerConvOnly, int fromTimestampInc, int toTimestampExc) {
1438
1439 Request request = null;
1440 try {
1441 request = new XCallRequest(0,136);
1442 } catch (IOException e) {
1443 e.printStackTrace();
1444 if (errorListener != null)
1445 errorListener.OnSkypeKitFatalError();
1446 }
1447 request.addParm('e',1,type.getId());
1448 request.addParm('b',2,latestPerConvOnly);
1449 request.addParm('u',3,fromTimestampInc);
1450 request.addParm('u',4,toTimestampExc);
1451
1452 Response r = XCall((XCallRequest)request);
1453
1454 if (r.isErrCall())
1455 return null;
1456
1457 Vector<Message> messages = new Vector<Message>();
1458 while (r.HasMore(1))
1459 {
1460 int oid = 0;
1461 Message message = null;
1462 oid = r.GetOid(1);
1463 if (oid != AbstractDecoder.NULL_VALUE) {
1464 message = (Message)skype.factory(Message.moduleID(), oid, skype);
1465 }
1466 messages.add(message);
1467 }
1468 return messages.toArray(new Message[messages.size()]);
1469
1470 }
1471
1472 /**
1473 *This method returns a table in form of two string lists of equal length and an uint argument that returns the count of items i both lists. The first list contains video recording device handles and the second list descriptive names of those devices. NB! This method requires videortphost to be running, otherwise it will return empty lists. <br>
1474 * @return GetAvailableVideoDevicesResult
1475 */
1476 public GetAvailableVideoDevicesResult GetAvailableVideoDevices() {
1477
1478 Request request = null;
1479 try {
1480 request = new XCallRequest(0,80);
1481 } catch (IOException e) {
1482 e.printStackTrace();
1483 if (errorListener != null)
1484 errorListener.OnSkypeKitFatalError();
1485 }
1486
1487 Response r = XCall((XCallRequest)request);
1488
1489 if (r.isErrCall())
1490 return null;
1491
1492 GetAvailableVideoDevicesResult result = new GetAvailableVideoDevicesResult();
1493
1494 Vector<String> deviceNames = new Vector<String>();
1495 while (r.HasMore(1))
1496 {
1497 String string = null;
1498 string = r.GetAsString(1);
1499 deviceNames.add(string);
1500 }
1501 result.deviceNames = deviceNames.toArray(new String[deviceNames.size()]);
1502
1503 Vector<String> devicePaths = new Vector<String>();
1504 while (r.HasMore(2))
1505 {
1506 String string = null;
1507 string = r.GetAsString(2);
1508 devicePaths.add(string);
1509 }
1510 result.devicePaths = devicePaths.toArray(new String[devicePaths.size()]);
1511
1512 int count = 0;
1513 count = r.GetAsInt(3);
1514 result.count = count;
1515
1516 return result;
1517 }
1518
1519 public class GetAvailableVideoDevicesResult {
1520 public String [] deviceNames;
1521 public String [] devicePaths;
1522 public int count;
1523 }
1524
1525 /**
1526 *Queries whether the given video device has a specific Video.VIDEO_DEVICE_CAPABILITY. Use Skype.GetAvailableVideoDevices method to retrieve sstring lists with available deviceName and devicePath values. <br>
1527 * @param deviceName Human readable device name. <br>
1528 * @param devicePath Device ID. <br>
1529 * @param cap Any of the Video.VIDEO_DEVICE_CAPABILITY values. <br>
1530 */
1531 public void HasVideoDeviceCapability( String deviceName, String devicePath, Video.VIDEO_DEVICE_CAPABILITY cap) {
1532
1533 Request request = null;
1534 try {
1535 request = new XCallRequest(0,33);
1536 } catch (IOException e) {
1537 e.printStackTrace();
1538 if (errorListener != null)
1539 errorListener.OnSkypeKitFatalError();
1540 }
1541 request.addParm('S',1,deviceName);
1542 request.addParm('S',2,devicePath);
1543 request.addParm('e',3,cap.getId());
1544
1545 XCall((XCallRequest)request);
1546 }
1547
1548 /**
1549 * @param deviceName
1550 * @param devicePath
1551 */
1552 public void DisplayVideoDeviceTuningDialog( String deviceName, String devicePath) {
1553
1554 Request request = null;
1555 try {
1556 request = new XCallRequest(0,34);
1557 } catch (IOException e) {
1558 e.printStackTrace();
1559 if (errorListener != null)
1560 errorListener.OnSkypeKitFatalError();
1561 }
1562 request.addParm('S',1,deviceName);
1563 request.addParm('S',2,devicePath);
1564
1565 XCall((XCallRequest)request);
1566 }
1567
1568 /**
1569 * @param type
1570 * @param deviceName name and path to be used only with media type VIDEO
1571 * @param devicePath
1572 * @return video
1573 */
1574 public Video GetPreviewVideo( Video.MEDIATYPE type, String deviceName, String devicePath) {
1575
1576 Request request = null;
1577 try {
1578 request = new XCallRequest(0,35);
1579 } catch (IOException e) {
1580 e.printStackTrace();
1581 if (errorListener != null)
1582 errorListener.OnSkypeKitFatalError();
1583 }
1584 request.addParm('e',1,type.getId());
1585 request.addParm('S',2,deviceName);
1586 request.addParm('S',3,devicePath);
1587
1588 Response r = XCall((XCallRequest)request);
1589
1590 if (r.isErrCall())
1591 return null;
1592
1593 int oid = 0;
1594 Video video = null;
1595 oid = r.GetOid(1);
1596 if (oid != AbstractDecoder.NULL_VALUE) {
1597 video = (Video)skype.factory(Video.moduleID(), oid, skype);
1598 }
1599 return video;
1600 }
1601
1602 /**
1603 *Avaible to Video Engines using the Video RTP API
1604 * @param command
1605 * @return response
1606 */
1607 public String VideoCommand( String command) {
1608
1609 Request request = null;
1610 try {
1611 request = new XCallRequest(0,59);
1612 } catch (IOException e) {
1613 e.printStackTrace();
1614 if (errorListener != null)
1615 errorListener.OnSkypeKitFatalError();
1616 }
1617 request.addParm('S',1,command);
1618
1619 Response r = XCall((XCallRequest)request);
1620
1621 if (r.isErrCall())
1622 return null;
1623
1624 String response = null;
1625 response = r.GetAsString(1);
1626 return response;
1627 }
1628
1629 /**
1630 * @param skypeName
1631 * @return greeting
1632 */
1633 public Voicemail GetGreeting( String skypeName) {
1634
1635 Request request = null;
1636 try {
1637 request = new XCallRequest(0,45);
1638 } catch (IOException e) {
1639 e.printStackTrace();
1640 if (errorListener != null)
1641 errorListener.OnSkypeKitFatalError();
1642 }
1643 request.addParm('S',1,skypeName);
1644
1645 Response r = XCall((XCallRequest)request);
1646
1647 if (r.isErrCall())
1648 return null;
1649
1650 int oid = 0;
1651 Voicemail greeting = null;
1652 oid = r.GetOid(1);
1653 if (oid != AbstractDecoder.NULL_VALUE) {
1654 greeting = (Voicemail)skype.factory(Voicemail.moduleID(), oid, skype);
1655 }
1656 return greeting;
1657 }
1658
1659 /** Setupkey SETUPKEY_DISABLED_CODECS type:string <br>Space-separated array of disabled codecs <br>This setup key is machine-specific and affects all local accounts. <br> */
1660 public static final String DISABLED_CODECS = "*Lib/Audio/DisableCodecs";
1661
1662 /** Setupkey SETUPKEY_DISABLE_AEC type:boolean <br>Disables Skype echo canceller <br>This setup key is machine-specific and affects all local accounts. <br> */
1663 public static final String DISABLE_AEC = "*Lib/Audio/DisableAEC";
1664
1665 /** Setupkey SETUPKEY_DISABLE_NOISE_SUPPRESSOR type:boolean <br>Disables Skype noise suppressor <br>This setup key is machine-specific and affects all local accounts. <br> */
1666 public static final String DISABLE_NOISE_SUPPRESSOR = "*Lib/Audio/DisableNS";
1667
1668 /** Setupkey SETUPKEY_DISABLE_AGC type:boolean Disables Skype automatic gain controller <br>This setup key is machine-specific and affects all local accounts. <br> */
1669 public static final String DISABLE_AGC = "*Lib/Audio/DisableAGC";
1670
1671 /** Setupkey SETUPKEY_DISABLE_DIGITAL_NEAR_END_AGC type:boolean <br>Disables Skype digital near-end gain controller <br>This setup key is machine-specific and affects all local accounts. <br> */
1672 public static final String DISABLE_DIGITAL_NEAR_END_AGC = "*Lib/Audio/DisableDigitalNearEndAGC";
1673
1674 /** Setupkey SETUPKEY_DISABLE_DIGITAL_FAR_END_AGC type:boolean <br>Disables Skype digital far-end gain controller <br>This setup key is machine-specific and affects all local accounts. <br> */
1675 public static final String DISABLE_DIGITAL_FAR_END_AGC = "*Lib/Audio/DisableDigitalFarEndAGC";
1676
1677 /** Setupkey SETUPKEY_BEAMFORMER_MIC_SPACING type:string <br>Space-separated array of 1 (in case of 2 microphones) or 2 (in case of 4 microphones) integers. SAL beamforming currently only supports 2 and 4-microphone configurations. The values represent the spacing between microphones (in millimeters). <br>In case of 2-microphone setup, Only the first value is used. <br><br>In case of 4-microphone setup, The first value is the distance between inner pair of microphones. The second value is the distance between inner pair of microphones and the outer pair. Like this: <br><br>Let the microphones be on straight line, A B C D. <br>Microphones B and C form the inner pair, while A and D form the outer pair. <br>The first value in the setup string would be distance between B and C. <br>The second value would be distance between A and B (which is the same as distance between C and D). <br><br>With 4-mic setup, you will need to use two channels. The inner pair should go to one channel (left) and the outer pair should go to another (right). <br><br>This setup key is machine-specific and affects all local accounts. <br> */
1678 public static final String BEAMFORMER_MIC_SPACING = "*Lib/Audio/BeamformerMicSpacing";
1679
1680 /** Setupkey SETUPKEY_DISABLE_AUDIO_DEVICE_PROBING type:boolean <br>Disables audio devices probing <br>This setup key is machine-specific and affects all local accounts. <br> */
1681 public static final String DISABLE_AUDIO_DEVICE_PROBING = "*Lib/QualityMonitor/DisableAudioDeviceProbing";
1682
1683 /**
1684 */
1685 public enum PREPARESOUNDRESULT {
1686
1687 /** */
1688 PREPARESOUND_SUCCESS(0),
1689
1690 /** */
1691 PREPARESOUND_MISC_ERROR(1),
1692
1693 /** */
1694 PREPARESOUND_FILE_NOT_FOUND(2),
1695
1696 /** */
1697 PREPARESOUND_FILE_TOO_BIG(3),
1698
1699 /** */
1700 PREPARESOUND_FILE_READ_ERROR(4),
1701
1702 /** */
1703 PREPARESOUND_UNSUPPORTED_FILE_FORMAT(5),
1704
1705 /** */
1706 PREPARESOUND_PLAYBACK_NOT_SUPPORTED(6);
1707
1708 private static final Map<Integer,PREPARESOUNDRESULT> lookup = new HashMap<Integer,PREPARESOUNDRESULT>();
1709
1710 static {
1711 for(PREPARESOUNDRESULT s : EnumSet.allOf(PREPARESOUNDRESULT.class))
1712 lookup.put(s.getId(), s);
1713 }
1714
1715 private final int id;
1716
1717 private PREPARESOUNDRESULT(int value) {
1718 this.id = value;
1719 }
1720
1721 public int getId() { return id; }
1722
1723 public static PREPARESOUNDRESULT get(int code) {
1724 return lookup.get(code);
1725 }
1726
1727 public static PREPARESOUNDRESULT fromString(String s) {
1728 for (PREPARESOUNDRESULT p : lookup.values()) {
1729 if (p.toString() == s) {
1730 return p;
1731 }
1732 }
1733 return null;
1734 }
1735 }
1736
1737 /**
1738 */
1739 public enum AUDIODEVICE_CAPABILITIES {
1740
1741 /** */
1742 HAS_VIDEO_CAPTURE(1),
1743
1744 /** */
1745 HAS_USB_INTERFACE(2),
1746
1747 /** */
1748 POSSIBLY_HEADSET(4),
1749
1750 /** */
1751 HAS_AUDIO_CAPTURE(8),
1752
1753 /** */
1754 HAS_AUDIO_RENDERING(16),
1755
1756 /** */
1757 HAS_LOWBANDWIDTH_CAPTURE(32),
1758
1759 /** */
1760 IS_WEBCAM(64),
1761
1762 /** */
1763 IS_HEADSET(128),
1764
1765 /** */
1766 POSSIBLY_WEBCAM(256),
1767
1768 /** */
1769 HAS_VIDEO_RENDERING(2048),
1770
1771 /** */
1772 HAS_BLUETOOTH_INTERFACE(4096);
1773
1774 private static final Map<Integer,AUDIODEVICE_CAPABILITIES> lookup = new HashMap<Integer,AUDIODEVICE_CAPABILITIES>();
1775
1776 static {
1777 for(AUDIODEVICE_CAPABILITIES s : EnumSet.allOf(AUDIODEVICE_CAPABILITIES.class))
1778 lookup.put(s.getId(), s);
1779 }
1780
1781 private final int id;
1782
1783 private AUDIODEVICE_CAPABILITIES(int value) {
1784 this.id = value;
1785 }
1786
1787 public int getId() { return id; }
1788
1789 public static AUDIODEVICE_CAPABILITIES get(int code) {
1790 return lookup.get(code);
1791 }
1792
1793 public static AUDIODEVICE_CAPABILITIES fromString(String s) {
1794 for (AUDIODEVICE_CAPABILITIES p : lookup.values()) {
1795 if (p.toString() == s) {
1796 return p;
1797 }
1798 }
1799 return null;
1800 }
1801 }
1802
1803 /**
1804 *Takes audio data that comes from the sound argument and mixes it into playback or notification device, depending on the value passed in the useCallOutDevice argument. The sound argument contains the audio data in in follwing format: first 4 bytes of the binary contain the sample rate, followed by 16 bit (mono) samples. The soundid argument is an arbitrary ID that you can pass in and then later use as an argument for Skype class PlayStop method. To mix the audio into playback device stream, set useCallOutDevice to true, to mic it into notification stream, set useCallOutDevice to false. <br>
1805 * @param soundid
1806 * @param sound
1807 * @param loop
1808 * @param useCallOutDevice
1809 */
1810 public void PlayStart( int soundid, byte[] sound, boolean loop, boolean useCallOutDevice) {
1811
1812 Request request = null;
1813 try {
1814 request = new XCallRequest(0,48);
1815 } catch (IOException e) {
1816 e.printStackTrace();
1817 if (errorListener != null)
1818 errorListener.OnSkypeKitFatalError();
1819 }
1820 request.addParm('u',1,soundid);
1821 request.addParm('B',2,sound);
1822 request.addParm('b',3,loop);
1823 request.addParm('b',4,useCallOutDevice);
1824
1825 XCall((XCallRequest)request);
1826 }
1827
1828 /**
1829 * @param soundid
1830 * @param datafile
1831 * @param loop
1832 * @param useCallOutDevice
1833 * @return result
1834 */
1835 public PREPARESOUNDRESULT PlayStartFromFile( int soundid, String datafile, boolean loop, boolean useCallOutDevice) {
1836
1837 Request request = null;
1838 try {
1839 request = new XCallRequest(0,212);
1840 } catch (IOException e) {
1841 e.printStackTrace();
1842 if (errorListener != null)
1843 errorListener.OnSkypeKitFatalError();
1844 }
1845 request.addParm('u',1,soundid);
1846 request.addParm('f',2,datafile);
1847 request.addParm('b',3,loop);
1848 request.addParm('b',4,useCallOutDevice);
1849
1850 Response r = XCall((XCallRequest)request);
1851
1852 if (r.isErrCall())
1853 return null;
1854
1855 PREPARESOUNDRESULT preparesoundresult = null;
1856 preparesoundresult = PREPARESOUNDRESULT.get(r.GetAsInt(1));
1857 return preparesoundresult;
1858 }
1859
1860 /**
1861 *Stops playback of the soundfile. The argument is the same ID you passed in the Skype class StartPlayback method. <br>
1862 * @param soundid
1863 */
1864 public void PlayStop( int soundid) {
1865
1866 Request request = null;
1867 try {
1868 request = new XCallRequest(0,49);
1869 } catch (IOException e) {
1870 e.printStackTrace();
1871 if (errorListener != null)
1872 errorListener.OnSkypeKitFatalError();
1873 }
1874 request.addParm('u',1,soundid);
1875
1876 XCall((XCallRequest)request);
1877 }
1878
1879 /**
1880 * @param recordAndPlaybackData
1881 */
1882 public void StartRecordingTest( boolean recordAndPlaybackData) {
1883
1884 Request request = null;
1885 try {
1886 request = new XCallRequest(0,50);
1887 } catch (IOException e) {
1888 e.printStackTrace();
1889 if (errorListener != null)
1890 errorListener.OnSkypeKitFatalError();
1891 }
1892 request.addParm('b',1,recordAndPlaybackData);
1893
1894 XCall((XCallRequest)request);
1895 }
1896
1897 /**
1898 */
1899 public void StopRecordingTest() {
1900
1901 Request request = null;
1902 try {
1903 request = new XCallRequest(0,51);
1904 } catch (IOException e) {
1905 e.printStackTrace();
1906 if (errorListener != null)
1907 errorListener.OnSkypeKitFatalError();
1908 }
1909
1910 XCall((XCallRequest)request);
1911 }
1912
1913 /**
1914 *This method returns a table in form of three string lists of equal lengths. The first list contains audio output device handles ('hw:0,0', 'hw:0,1', etc.) The second list contains descriptive names of those devices (Ensoniq AudioPCI etc.) The third list contains device product IDs. Note that the values in these lists depend on which audio engine you are running (SAL, PCM, RTP). <br>
1915 * @return GetAvailableOutputDevicesResult
1916 */
1917 public GetAvailableOutputDevicesResult GetAvailableOutputDevices() {
1918
1919 Request request = null;
1920 try {
1921 request = new XCallRequest(0,53);
1922 } catch (IOException e) {
1923 e.printStackTrace();
1924 if (errorListener != null)
1925 errorListener.OnSkypeKitFatalError();
1926 }
1927
1928 Response r = XCall((XCallRequest)request);
1929
1930 if (r.isErrCall())
1931 return null;
1932
1933 GetAvailableOutputDevicesResult result = new GetAvailableOutputDevicesResult();
1934
1935 Vector<String> handleList = new Vector<String>();
1936 while (r.HasMore(1))
1937 {
1938 String string = null;
1939 string = r.GetAsString(1);
1940 handleList.add(string);
1941 }
1942 result.handleList = handleList.toArray(new String[handleList.size()]);
1943
1944 Vector<String> nameList = new Vector<String>();
1945 while (r.HasMore(2))
1946 {
1947 String string = null;
1948 string = r.GetAsString(2);
1949 nameList.add(string);
1950 }
1951 result.nameList = nameList.toArray(new String[nameList.size()]);
1952
1953 Vector<String> productIdList = new Vector<String>();
1954 while (r.HasMore(3))
1955 {
1956 String string = null;
1957 string = r.GetAsString(3);
1958 productIdList.add(string);
1959 }
1960 result.productIdList = productIdList.toArray(new String[productIdList.size()]);
1961
1962 return result;
1963 }
1964
1965 public class GetAvailableOutputDevicesResult {
1966 public String [] handleList;
1967 public String [] nameList;
1968 public String [] productIdList;
1969 }
1970
1971 /**
1972 *This method returns a table in form of three string lists of equal length. The first list contains audio recording device handles ('hw:0,0', 'hw:0,1', etc.) The second list contains descriptive names of those devices (Ensoniq AudioPCI etc.) The third list contains device product IDs. Note that the values in these lists depend on which audio engine you are running (SAL, PCM, RTP). <br>
1973 * @return GetAvailableRecordingDevicesResult
1974 */
1975 public GetAvailableRecordingDevicesResult GetAvailableRecordingDevices() {
1976
1977 Request request = null;
1978 try {
1979 request = new XCallRequest(0,54);
1980 } catch (IOException e) {
1981 e.printStackTrace();
1982 if (errorListener != null)
1983 errorListener.OnSkypeKitFatalError();
1984 }
1985
1986 Response r = XCall((XCallRequest)request);
1987
1988 if (r.isErrCall())
1989 return null;
1990
1991 GetAvailableRecordingDevicesResult result = new GetAvailableRecordingDevicesResult();
1992
1993 Vector<String> handleList = new Vector<String>();
1994 while (r.HasMore(1))
1995 {
1996 String string = null;
1997 string = r.GetAsString(1);
1998 handleList.add(string);
1999 }
2000 result.handleList = handleList.toArray(new String[handleList.size()]);
2001
2002 Vector<String> nameList = new Vector<String>();
2003 while (r.HasMore(2))
2004 {
2005 String string = null;
2006 string = r.GetAsString(2);
2007 nameList.add(string);
2008 }
2009 result.nameList = nameList.toArray(new String[nameList.size()]);
2010
2011 Vector<String> productIdList = new Vector<String>();
2012 while (r.HasMore(3))
2013 {
2014 String string = null;
2015 string = r.GetAsString(3);
2016 productIdList.add(string);
2017 }
2018 result.productIdList = productIdList.toArray(new String[productIdList.size()]);
2019
2020 return result;
2021 }
2022
2023 public class GetAvailableRecordingDevicesResult {
2024 public String [] handleList;
2025 public String [] nameList;
2026 public String [] productIdList;
2027 }
2028
2029 /**
2030 *Sets audio devices given in arguments as active audio devices. This command selects all three devices - microphone, playback and the notification channel. Valid input values for this method come from the first string list you get back from Skype class GetAvailableOutputDevices (handleList). <br>
2031 * @param callInDevice
2032 * @param callOutDevice
2033 * @param waveOutDevice
2034 */
2035 public void SelectSoundDevices( String callInDevice, String callOutDevice, String waveOutDevice) {
2036
2037 Request request = null;
2038 try {
2039 request = new XCallRequest(0,55);
2040 } catch (IOException e) {
2041 e.printStackTrace();
2042 if (errorListener != null)
2043 errorListener.OnSkypeKitFatalError();
2044 }
2045 request.addParm('S',1,callInDevice);
2046 request.addParm('S',2,callOutDevice);
2047 request.addParm('S',3,waveOutDevice);
2048
2049 XCall((XCallRequest)request);
2050 }
2051
2052 /**
2053 *The uint argument returns AUDIODEVICE_CAPABILITIES (declared in Skype class) <br>
2054 * @param deviceHandle
2055 * @return GetAudioDeviceCapabilitiesResult
2056 */
2057 public GetAudioDeviceCapabilitiesResult GetAudioDeviceCapabilities( String deviceHandle) {
2058
2059 Request request = null;
2060 try {
2061 request = new XCallRequest(0,56);
2062 } catch (IOException e) {
2063 e.printStackTrace();
2064 if (errorListener != null)
2065 errorListener.OnSkypeKitFatalError();
2066 }
2067 request.addParm('S',1,deviceHandle);
2068
2069 Response r = XCall((XCallRequest)request);
2070
2071 if (r.isErrCall())
2072 return null;
2073
2074 GetAudioDeviceCapabilitiesResult result = new GetAudioDeviceCapabilitiesResult();
2075
2076 String interfaceString = null;
2077 interfaceString = r.GetAsString(1);
2078 result.interfaceString = interfaceString;
2079
2080 int capabilities = 0;
2081 capabilities = r.GetAsInt(2);
2082 result.capabilities = capabilities;
2083
2084 return result;
2085 }
2086
2087 public class GetAudioDeviceCapabilitiesResult {
2088 public String interfaceString;
2089 public int capabilities; /** bit set of AUDIODEVICE_CAPABILITIES */
2090 }
2091
2092 /**
2093 *Returns current audio stream volume for both playback and microphone streams. Useful for displaying visual audio indicators in you UI. See also Skype class OnNrgLevelsChange callback that gets fired each time the these values are changed. <br>
2094 * @return GetNrgLevelsResult
2095 */
2096 public GetNrgLevelsResult GetNrgLevels() {
2097
2098 Request request = null;
2099 try {
2100 request = new XCallRequest(0,57);
2101 } catch (IOException e) {
2102 e.printStackTrace();
2103 if (errorListener != null)
2104 errorListener.OnSkypeKitFatalError();
2105 }
2106
2107 Response r = XCall((XCallRequest)request);
2108
2109 if (r.isErrCall())
2110 return null;
2111
2112 GetNrgLevelsResult result = new GetNrgLevelsResult();
2113
2114 int micLevel = 0;
2115 micLevel = r.GetAsInt(1);
2116 result.micLevel = micLevel;
2117
2118 int speakerLevel = 0;
2119 speakerLevel = r.GetAsInt(2);
2120 result.speakerLevel = speakerLevel;
2121
2122 return result;
2123 }
2124
2125 public class GetNrgLevelsResult {
2126 public int micLevel;
2127 public int speakerLevel;
2128 }
2129
2130 /**
2131 *NB! This command only works if its implemented in external audiohost (RTP or PCM host). The command can be is used for passing custom commands from client UI to the audio implementation. <br>
2132 * @param command
2133 * @return response
2134 */
2135 public String VoiceCommand( String command) {
2136
2137 Request request = null;
2138 try {
2139 request = new XCallRequest(0,58);
2140 } catch (IOException e) {
2141 e.printStackTrace();
2142 if (errorListener != null)
2143 errorListener.OnSkypeKitFatalError();
2144 }
2145 request.addParm('S',1,command);
2146
2147 Response r = XCall((XCallRequest)request);
2148
2149 if (r.isErrCall())
2150 return null;
2151
2152 String response = null;
2153 response = r.GetAsString(1);
2154 return response;
2155 }
2156
2157 /**
2158 *Returns value of audio playback volume setting (0..100). <br>
2159 * @return volume
2160 */
2161 public int GetSpeakerVolume() {
2162
2163 Request request = null;
2164 try {
2165 request = new XCallRequest(0,60);
2166 } catch (IOException e) {
2167 e.printStackTrace();
2168 if (errorListener != null)
2169 errorListener.OnSkypeKitFatalError();
2170 }
2171
2172 Response r = XCall((XCallRequest)request);
2173
2174 if (r.isErrCall())
2175 return 0;
2176
2177 int volume = 0;
2178 volume = r.GetAsInt(1);
2179 return volume;
2180 }
2181
2182 /**
2183 *This method is for setting speaker volume. It will set the level for Skype digital gain control. Skype audio library will not control gain of audio device itself. <br>
2184 * @param volume
2185 */
2186 public void SetSpeakerVolume( int volume) {
2187
2188 Request request = null;
2189 try {
2190 request = new XCallRequest(0,61);
2191 } catch (IOException e) {
2192 e.printStackTrace();
2193 if (errorListener != null)
2194 errorListener.OnSkypeKitFatalError();
2195 }
2196 request.addParm('u',1,volume);
2197
2198 XCall((XCallRequest)request);
2199 }
2200
2201 /**
2202 *Returns value of microphone volume setting (0..100). It will return the analog gain of audio device set by Skype AGC. For real-time microphone volume, use GetNrgLevels method or OnNrgLevelsChange callback (both are methods of Skype class). <br>
2203 * @return micVolume
2204 */
2205 public int GetMicVolume() {
2206
2207 Request request = null;
2208 try {
2209 request = new XCallRequest(0,62);
2210 } catch (IOException e) {
2211 e.printStackTrace();
2212 if (errorListener != null)
2213 errorListener.OnSkypeKitFatalError();
2214 }
2215
2216 Response r = XCall((XCallRequest)request);
2217
2218 if (r.isErrCall())
2219 return 0;
2220
2221 int micVolume = 0;
2222 micVolume = r.GetAsInt(1);
2223 return micVolume;
2224 }
2225
2226 /**
2227 *This method is for setting the microphone volume level. This does not work when Skype AGC (Automatic Gain Control) is enabled, which it is by default. It is currently impossible to disable AGC, so for now this method is here for purpose of future compatibility. <br>
2228 * @param volume
2229 */
2230 public void SetMicVolume( int volume) {
2231
2232 Request request = null;
2233 try {
2234 request = new XCallRequest(0,63);
2235 } catch (IOException e) {
2236 e.printStackTrace();
2237 if (errorListener != null)
2238 errorListener.OnSkypeKitFatalError();
2239 }
2240 request.addParm('u',1,volume);
2241
2242 XCall((XCallRequest)request);
2243 }
2244
2245 /**
2246 *Returns true in &muted argument if the currently selected playback device is muted. <br>
2247 * @return muted
2248 */
2249 public boolean IsSpeakerMuted() {
2250
2251 Request request = null;
2252 try {
2253 request = new XCallRequest(0,64);
2254 } catch (IOException e) {
2255 e.printStackTrace();
2256 if (errorListener != null)
2257 errorListener.OnSkypeKitFatalError();
2258 }
2259
2260 Response r = XCall((XCallRequest)request);
2261
2262 if (r.isErrCall())
2263 return false;
2264
2265 boolean muted = false;
2266 muted = r.GetAsBoolean(1);
2267 return muted;
2268 }
2269
2270 /**
2271 *Returns true in &muted argument if the currently selected microphone is muted. <br>
2272 * @return muted
2273 */
2274 public boolean IsMicrophoneMuted() {
2275
2276 Request request = null;
2277 try {
2278 request = new XCallRequest(0,65);
2279 } catch (IOException e) {
2280 e.printStackTrace();
2281 if (errorListener != null)
2282 errorListener.OnSkypeKitFatalError();
2283 }
2284
2285 Response r = XCall((XCallRequest)request);
2286
2287 if (r.isErrCall())
2288 return false;
2289
2290 boolean muted = false;
2291 muted = r.GetAsBoolean(1);
2292 return muted;
2293 }
2294
2295 /**
2296 *Sets currently selected playback device mute status according to argument. <br>
2297 * @param mute
2298 */
2299 public void MuteSpeakers( boolean mute) {
2300
2301 Request request = null;
2302 try {
2303 request = new XCallRequest(0,66);
2304 } catch (IOException e) {
2305 e.printStackTrace();
2306 if (errorListener != null)
2307 errorListener.OnSkypeKitFatalError();
2308 }
2309 request.addParm('b',1,mute);
2310
2311 XCall((XCallRequest)request);
2312 }
2313
2314 /**
2315 *Sets currently selected microphone mute status according to argument. <br>
2316 * @param mute
2317 */
2318 public void MuteMicrophone( boolean mute) {
2319
2320 Request request = null;
2321 try {
2322 request = new XCallRequest(0,67);
2323 } catch (IOException e) {
2324 e.printStackTrace();
2325 if (errorListener != null)
2326 errorListener.OnSkypeKitFatalError();
2327 }
2328 request.addParm('b',1,mute);
2329
2330 XCall((XCallRequest)request);
2331 }
2332
2333 /**
2334 */
2335 public enum OPERATING_MEDIA {
2336
2337 /** */
2338 OM_UNKNOWN(0),
2339
2340 /** */
2341 OM_FREE(1),
2342
2343 /** */
2344 OM_FREE_WIRELESS(2),
2345
2346 /** */
2347 OM_3G(3),
2348
2349 /** */
2350 OM_4G(4);
2351
2352 private static final Map<Integer,OPERATING_MEDIA> lookup = new HashMap<Integer,OPERATING_MEDIA>();
2353
2354 static {
2355 for(OPERATING_MEDIA s : EnumSet.allOf(OPERATING_MEDIA.class))
2356 lookup.put(s.getId(), s);
2357 }
2358
2359 private final int id;
2360
2361 private OPERATING_MEDIA(int value) {
2362 this.id = value;
2363 }
2364
2365 public int getId() { return id; }
2366
2367 public static OPERATING_MEDIA get(int code) {
2368 return lookup.get(code);
2369 }
2370
2371 public static OPERATING_MEDIA fromString(String s) {
2372 for (OPERATING_MEDIA p : lookup.values()) {
2373 if (p.toString() == s) {
2374 return p;
2375 }
2376 }
2377 return null;
2378 }
2379 }
2380
2381 /**
2382 * @param media
2383 * @param maxUplinkBps
2384 * @param maxDownlinkBps
2385 */
2386 public void SetOperatingMedia( OPERATING_MEDIA media, int maxUplinkBps, int maxDownlinkBps) {
2387
2388 Request request = null;
2389 try {
2390 request = new XCallRequest(0,255);
2391 } catch (IOException e) {
2392 e.printStackTrace();
2393 if (errorListener != null)
2394 errorListener.OnSkypeKitFatalError();
2395 }
2396 request.addParm('e',1,media.getId());
2397 request.addParm('u',2,maxUplinkBps);
2398 request.addParm('u',3,maxDownlinkBps);
2399
2400 XCall((XCallRequest)request);
2401 }
2402
2403 /**
2404 *creates an CONFIRMATION_CODE_REQUEST SMS message
2405 * @param type
2406 * @param number
2407 * @return sms
2408 */
2409 public Sms RequestConfirmationCode( Sms.CONFIRM_TYPE type, String number) {
2410
2411 Request request = null;
2412 try {
2413 request = new XCallRequest(0,29);
2414 } catch (IOException e) {
2415 e.printStackTrace();
2416 if (errorListener != null)
2417 errorListener.OnSkypeKitFatalError();
2418 }
2419 request.addParm('e',1,type.getId());
2420 request.addParm('S',2,number);
2421
2422 Response r = XCall((XCallRequest)request);
2423
2424 if (r.isErrCall())
2425 return null;
2426
2427 int oid = 0;
2428 Sms sms = null;
2429 oid = r.GetOid(1);
2430 if (oid != AbstractDecoder.NULL_VALUE) {
2431 sms = (Sms)skype.factory(Sms.moduleID(), oid, skype);
2432 }
2433 return sms;
2434 }
2435
2436 /**
2437 *creates an CONFIRMATION_CODE_REQUEST SMS message
2438 * @param number
2439 * @param code
2440 * @return sms
2441 */
2442 public Sms SubmitConfirmationCode( String number, String code) {
2443
2444 Request request = null;
2445 try {
2446 request = new XCallRequest(0,30);
2447 } catch (IOException e) {
2448 e.printStackTrace();
2449 if (errorListener != null)
2450 errorListener.OnSkypeKitFatalError();
2451 }
2452 request.addParm('S',1,number);
2453 request.addParm('S',2,code);
2454
2455 Response r = XCall((XCallRequest)request);
2456
2457 if (r.isErrCall())
2458 return null;
2459
2460 int oid = 0;
2461 Sms sms = null;
2462 oid = r.GetOid(1);
2463 if (oid != AbstractDecoder.NULL_VALUE) {
2464 sms = (Sms)skype.factory(Sms.moduleID(), oid, skype);
2465 }
2466 return sms;
2467 }
2468
2469 /**
2470 *creates an OUTGOING/COMPOSING SMS message
2471 * @return sms
2472 */
2473 public Sms CreateOutgoingSms() {
2474
2475 Request request = null;
2476 try {
2477 request = new XCallRequest(0,70);
2478 } catch (IOException e) {
2479 e.printStackTrace();
2480 if (errorListener != null)
2481 errorListener.OnSkypeKitFatalError();
2482 }
2483
2484 Response r = XCall((XCallRequest)request);
2485
2486 if (r.isErrCall())
2487 return null;
2488
2489 int oid = 0;
2490 Sms sms = null;
2491 oid = r.GetOid(1);
2492 if (oid != AbstractDecoder.NULL_VALUE) {
2493 sms = (Sms)skype.factory(Sms.moduleID(), oid, skype);
2494 }
2495 return sms;
2496 }
2497
2498 /** Setupkey SETUPKEY_FT_AUTOACCEPT type:int <br>Controls file transfer auto-accept. <br> - 0 - off <br> - 1 - on <br>This is account-specific setup key. It can only be used while an account is logged in. <br> */
2499 public static final String FT_AUTOACCEPT = "Lib/FileTransfer/AutoAccept";
2500
2501 /** Setupkey SETUPKEY_FT_SAVEPATH type:string <br>Full local path to save incoming file transfers (used for AutoAccept feature) <br>This is account-specific setup key. It can only be used while an account is logged in. <br> */
2502 public static final String FT_SAVEPATH = "Lib/FileTransfer/SavePath";
2503
2504 /** Setupkey SETUPKEY_FT_INCOMING_LIMIT type:uint <br>Number of simultaneous incoming file transfers (per user). Value 0 means no limitation. <br>This is account-specific setup key. It can only be used while an account is logged in. <br> */
2505 public static final String FT_INCOMING_LIMIT = "Lib/FileTransfer/IncomingLimit";
2506
2507 /** Setupkey SETUPKEY_IDLE_TIME_FOR_AWAY type:int <br>Number of seconds since the last keyboard or mouse activity, after which the online status of currently logged in account should be set to AWAY. See Account.SetAvailability method for more information. <br>This is account-specific setup key. It can only be used while an account is logged in. <br> */
2508 public static final String IDLE_TIME_FOR_AWAY = "Lib/Account/IdleTimeForAway";
2509
2510 /** Setupkey SETUPKEY_IDLE_TIME_FOR_NA type:int <br>The Contact.AVAILABILITY.NOT_AVAILABLE online status has been deprecated. This setup key is no longer in use. <br> */
2511 public static final String IDLE_TIME_FOR_NA = "Lib/Account/IdleTimeForNA";
2512
2513 /**
2514 *Retrieves an Account object by Skype name (identity). This should normally be one of the first method calls after Skype object initialization. Nearly all the other methods require successful account login in order to work properly. The list of accounts that have been used on the local machine/database can be retrieved with Skype.GetExistingAccounts method. If a matching identity is not found, a new Account object is created. This object can then be used to populate requred fields and then use Account.Register method for new account creation. This method returns false on error. <br>
2515 * @param identity Account skypename. <br>
2516 * @return account Returns account object if successful. <br>
2517 */
2518 public Account GetAccount( String identity) {
2519
2520 Request request = null;
2521 try {
2522 request = new XCallRequest(0,115);
2523 } catch (IOException e) {
2524 e.printStackTrace();
2525 if (errorListener != null)
2526 errorListener.OnSkypeKitFatalError();
2527 }
2528 request.addParm('S',1,identity);
2529
2530 Response r = XCall((XCallRequest)request);
2531
2532 if (r.isErrCall())
2533 return null;
2534
2535 int oid = 0;
2536 Account account = null;
2537 oid = r.GetOid(1);
2538 if (oid != AbstractDecoder.NULL_VALUE) {
2539 if (! object_list.containsKey(oid)) {
2540 object_list.clear(); // #AABIP-7: Clear any other account's cached info from previous logins
2541 }
2542 account = (Account)skype.factory(Account.moduleID(), oid, skype);
2543 }
2544 return account;
2545 }
2546
2547 /**
2548 *Returns a list of possible profiles used before on this machine
2549 * @return accountNameList
2550 */
2551 public String [] GetExistingAccounts() {
2552
2553 Request request = null;
2554 try {
2555 request = new XCallRequest(0,113);
2556 } catch (IOException e) {
2557 e.printStackTrace();
2558 if (errorListener != null)
2559 errorListener.OnSkypeKitFatalError();
2560 }
2561
2562 Response r = XCall((XCallRequest)request);
2563
2564 if (r.isErrCall())
2565 return null;
2566
2567 Vector<String> accountNameList = new Vector<String>();
2568 while (r.HasMore(1))
2569 {
2570 String string = null;
2571 string = r.GetAsString(1);
2572 accountNameList.add(string);
2573 }
2574 return accountNameList.toArray(new String[accountNameList.size()]);
2575
2576 }
2577
2578 /**
2579 *return most recently used account that has pwd saved. empty string if none
2580 * @return account
2581 */
2582 public String GetDefaultAccountName() {
2583
2584 Request request = null;
2585 try {
2586 request = new XCallRequest(0,114);
2587 } catch (IOException e) {
2588 e.printStackTrace();
2589 if (errorListener != null)
2590 errorListener.OnSkypeKitFatalError();
2591 }
2592
2593 Response r = XCall((XCallRequest)request);
2594
2595 if (r.isErrCall())
2596 return null;
2597
2598 String account = null;
2599 account = r.GetAsString(1);
2600 return account;
2601 }
2602
2603 /**
2604 *suggest a nice skypename to go with given fullname
2605 * @param fullname
2606 * @return suggestedName
2607 */
2608 public String GetSuggestedSkypename( String fullname) {
2609
2610 Request request = null;
2611 try {
2612 request = new XCallRequest(0,116);
2613 } catch (IOException e) {
2614 e.printStackTrace();
2615 if (errorListener != null)
2616 errorListener.OnSkypeKitFatalError();
2617 }
2618 request.addParm('S',1,fullname);
2619
2620 Response r = XCall((XCallRequest)request);
2621
2622 if (r.isErrCall())
2623 return null;
2624
2625 String suggestedName = null;
2626 suggestedName = r.GetAsString(1);
2627 return suggestedName;
2628 }
2629
2630 /**
2631 A value of this type can be returned by one of the following methods (of Skype class): ValidateAvatar, ValidateProfileString, ValidatePassword. <br> */
2632 public enum VALIDATERESULT {
2633
2634 /** Given property could not be validated. The length of the field was within limits and the value is assumed to be Ok. Your client should treat this value as equivalent to VALIDATED_OK. <br>*/
2635 NOT_VALIDATED(0),
2636
2637 /** Avatar or profile string validation succeeded. <br>*/
2638 VALIDATED_OK(1),
2639
2640 /** Password is too short. <br>*/
2641 TOO_SHORT(2),
2642
2643 /** The value exceeds max size limit for the given property. <br>*/
2644 TOO_LONG(3),
2645
2646 /** Value contains illegal characters. <br>*/
2647 CONTAINS_INVALID_CHAR(4),
2648
2649 /** Value contains whitespace. <br>*/
2650 CONTAINS_SPACE(5),
2651
2652 /** Password cannot be the same as skypename. <br>*/
2653 SAME_AS_USERNAME(6),
2654
2655 /** Value has invalid format. <br>*/
2656 INVALID_FORMAT(7),
2657
2658 /** Value contains invalid word. <br>*/
2659 CONTAINS_INVALID_WORD(8),
2660
2661 /** Password is too simple. <br>*/
2662 TOO_SIMPLE(9),
2663
2664 /** Value starts with an invalid character. <br>*/
2665 STARTS_WITH_INVALID_CHAR(10);
2666
2667 private static final Map<Integer,VALIDATERESULT> lookup = new HashMap<Integer,VALIDATERESULT>();
2668
2669 static {
2670 for(VALIDATERESULT s : EnumSet.allOf(VALIDATERESULT.class))
2671 lookup.put(s.getId(), s);
2672 }
2673
2674 private final int id;
2675
2676 private VALIDATERESULT(int value) {
2677 this.id = value;
2678 }
2679
2680 public int getId() { return id; }
2681
2682 public static VALIDATERESULT get(int code) {
2683 return lookup.get(code);
2684 }
2685
2686 public static VALIDATERESULT fromString(String s) {
2687 for (VALIDATERESULT p : lookup.values()) {
2688 if (p.toString() == s) {
2689 return p;
2690 }
2691 }
2692 return null;
2693 }
2694 }
2695
2696 /**
2697 * @param value
2698 * @return ValidateAvatarResult
2699 */
2700 public ValidateAvatarResult ValidateAvatar( byte[] value) {
2701
2702 Request request = null;
2703 try {
2704 request = new XCallRequest(0,119);
2705 } catch (IOException e) {
2706 e.printStackTrace();
2707 if (errorListener != null)
2708 errorListener.OnSkypeKitFatalError();
2709 }
2710 request.addParm('B',1,value);
2711
2712 Response r = XCall((XCallRequest)request);
2713
2714 if (r.isErrCall())
2715 return null;
2716
2717 ValidateAvatarResult result = new ValidateAvatarResult();
2718
2719 VALIDATERESULT validateresult = null;
2720 validateresult = VALIDATERESULT.get(r.GetAsInt(1));
2721 result.result = validateresult;
2722
2723 int freeBytesLeft = 0;
2724 freeBytesLeft = r.GetAsInt(2);
2725 result.freeBytesLeft = freeBytesLeft;
2726
2727 return result;
2728 }
2729
2730 public class ValidateAvatarResult {
2731 public VALIDATERESULT result;
2732 public int freeBytesLeft;
2733 }
2734
2735 /**
2736 *This method should be used for validating skypenames before registering new accounts, if the propKey is set to SKYPENAME (Contact class) and forRegistration argument is set to true. If the forRegistration argument is false, only string length check is applied. It is also useful to probe, what the size limits are, for each string property (e.g. 300 characters for moodmessage) <br>
2737 * @param propKey
2738 * @param strValue
2739 * @param forRegistration
2740 * @return ValidateProfileStringResult
2741 */
2742 public ValidateProfileStringResult ValidateProfileString( int propKey, String strValue, boolean forRegistration) {
2743
2744 Request request = null;
2745 try {
2746 request = new XCallRequest(0,102);
2747 } catch (IOException e) {
2748 e.printStackTrace();
2749 if (errorListener != null)
2750 errorListener.OnSkypeKitFatalError();
2751 }
2752 request.addParm('e',1,propKey);
2753 request.addParm('S',2,strValue);
2754 request.addParm('b',3,forRegistration);
2755
2756 Response r = XCall((XCallRequest)request);
2757
2758 if (r.isErrCall())
2759 return null;
2760
2761 ValidateProfileStringResult result = new ValidateProfileStringResult();
2762
2763 VALIDATERESULT validateresult = null;
2764 validateresult = VALIDATERESULT.get(r.GetAsInt(1));
2765 result.result = validateresult;
2766
2767 int freeBytesLeft = 0;
2768 freeBytesLeft = r.GetAsInt(2);
2769 result.freeBytesLeft = freeBytesLeft;
2770
2771 return result;
2772 }
2773
2774 public class ValidateProfileStringResult {
2775 public VALIDATERESULT result;
2776 public int freeBytesLeft;
2777 }
2778
2779 /**
2780 *This method is for pre-validating account passwords before account creation or password change. The result will return either VALIDATED_OK or one of many possible reasons the password is unacceptable (too short, too simple, etc.) <br>
2781 * @param username
2782 * @param password
2783 * @return result
2784 */
2785 public VALIDATERESULT ValidatePassword( String username, String password) {
2786
2787 Request request = null;
2788 try {
2789 request = new XCallRequest(0,71);
2790 } catch (IOException e) {
2791 e.printStackTrace();
2792 if (errorListener != null)
2793 errorListener.OnSkypeKitFatalError();
2794 }
2795 request.addParm('S',1,username);
2796 request.addParm('S',2,password);
2797
2798 Response r = XCall((XCallRequest)request);
2799
2800 if (r.isErrCall())
2801 return null;
2802
2803 VALIDATERESULT validateresult = null;
2804 validateresult = VALIDATERESULT.get(r.GetAsInt(1));
2805 return validateresult;
2806 }
2807
2808 /** Setupkey SETUPKEY_PORT type:int <br>Suggested port number (lib will *try* to use that) <br>This setup key is machine-specific and affects all local accounts. <br> */
2809 public static final String PORT = "*Lib/Connection/Port";
2810
2811 /** Setupkey SETUPKEY_HTTPS_PROXY_ENABLE type:int <br>Set to 0 for automatic proxy detect, 1 to use proxy config below <br>This setup key is machine-specific and affects all local accounts. <br> */
2812 public static final String HTTPS_PROXY_ENABLE = "*Lib/Connection/HttpsProxy/Enable";
2813
2814 /** Setupkey SETUPKEY_HTTPS_PROXY_ADDR type:string <br>name:port of HTTP proxy server <br>This setup key is machine-specific and affects all local accounts. <br> */
2815 public static final String HTTPS_PROXY_ADDR = "*Lib/Connection/HttpsProxy/Addr";
2816
2817 /** Setupkey SETUPKEY_HTTPS_PROXY_USER type:string <br>HTTPS proxy server username <br>This setup key is machine-specific and affects all local accounts. <br> */
2818 public static final String HTTPS_PROXY_USER = "*Lib/Connection/HttpsProxy/User";
2819
2820 /** Setupkey SETUPKEY_HTTPS_PROXY_PWD type:string <br>HTTPS proxy server password (base64 encoded) <br>This setup key is machine-specific and affects all local accounts. <br> */
2821 public static final String HTTPS_PROXY_PWD = "*Lib/Connection/HttpsProxy/Pwd";
2822
2823 /** Setupkey SETUPKEY_SOCKS_PROXY_ENABLE type:int <br>Set to non-zero to enable socks proxy support <br>This setup key is machine-specific and affects all local accounts. <br> */
2824 public static final String SOCKS_PROXY_ENABLE = "*Lib/Connection/SocksProxy/Enable";
2825
2826 /** Setupkey SETUPKEY_SOCKS_PROXY_ADDR type:string <br>name:port of SOCKS proxy server <br>This setup key is machine-specific and affects all local accounts. <br> */
2827 public static final String SOCKS_PROXY_ADDR = "*Lib/Connection/SocksProxy/Addr";
2828
2829 /** Setupkey SETUPKEY_SOCKS_PROXY_USER type:string <br>SOCKS proxy server username <br>This setup key is machine-specific and affects all local accounts. <br> */
2830 public static final String SOCKS_PROXY_USER = "*Lib/Connection/SocksProxy/User";
2831
2832 /** Setupkey SETUPKEY_SOCKS_PROXY_PWD type:string <br>SOCKS proxy server password (base64 encoded) <br>This setup key is machine-specific and affects all local accounts. <br> */
2833 public static final String SOCKS_PROXY_PWD = "*Lib/Connection/SocksProxy/Pwd";
2834
2835 /** Setupkey SETUPKEY_LOCALADDRESS type:string <br>local interface to listen to <br>This setup key is machine-specific and affects all local accounts. <br> */
2836 public static final String LOCALADDRESS = "*Lib/Connection/LocalAddress";
2837
2838 /** Setupkey SETUPKEY_DISABLE_PORT80 type:int <br>1 disables listening of alternative ports (80, 443) <br>This setup key is machine-specific and affects all local accounts. <br> */
2839 public static final String DISABLE_PORT80 = "*Lib/Connection/DisablePort80";
2840
2841 /** Setupkey SETUPKEY_DISABLE_UDP type:int <br>1 disables UDP port binding. should be set before connect <br>This setup key is machine-specific and affects all local accounts. <br> */
2842 public static final String DISABLE_UDP = "*Lib/Connection/DisableUDP";
2843
2844 /**
2845 */
2846 public enum PROXYTYPE {
2847
2848 /** */
2849 HTTPS_PROXY(0),
2850
2851 /** */
2852 SOCKS_PROXY(1);
2853
2854 private static final Map<Integer,PROXYTYPE> lookup = new HashMap<Integer,PROXYTYPE>();
2855
2856 static {
2857 for(PROXYTYPE s : EnumSet.allOf(PROXYTYPE.class))
2858 lookup.put(s.getId(), s);
2859 }
2860
2861 private final int id;
2862
2863 private PROXYTYPE(int value) {
2864 this.id = value;
2865 }
2866
2867 public int getId() { return id; }
2868
2869 public static PROXYTYPE get(int code) {
2870 return lookup.get(code);
2871 }
2872
2873 public static PROXYTYPE fromString(String s) {
2874 for (PROXYTYPE p : lookup.values()) {
2875 if (p.toString() == s) {
2876 return p;
2877 }
2878 }
2879 return null;
2880 }
2881 }
2882
2883 /**
2884 *This is used for retrieving local setup keys of type string. For more information, see Defines section in the skype-embedded_2.h <br>
2885 * @param key
2886 * @return value
2887 */
2888 public String GetStr( String key) {
2889
2890 Request request = null;
2891 try {
2892 request = new XCallRequest(0,120);
2893 } catch (IOException e) {
2894 e.printStackTrace();
2895 if (errorListener != null)
2896 errorListener.OnSkypeKitFatalError();
2897 }
2898 request.addParm('S',1,key);
2899
2900 Response r = XCall((XCallRequest)request);
2901
2902 if (r.isErrCall())
2903 return null;
2904
2905 String value = null;
2906 value = r.GetAsString(1);
2907 return value;
2908 }
2909
2910 /**
2911 *This is used for retrieving local setup keys of type int. For more information, see Defines section in the skype-embedded_2.h <br>
2912 * @param key
2913 * @return value
2914 */
2915 public int GetInt( String key) {
2916
2917 Request request = null;
2918 try {
2919 request = new XCallRequest(0,121);
2920 } catch (IOException e) {
2921 e.printStackTrace();
2922 if (errorListener != null)
2923 errorListener.OnSkypeKitFatalError();
2924 }
2925 request.addParm('S',1,key);
2926
2927 Response r = XCall((XCallRequest)request);
2928
2929 if (r.isErrCall())
2930 return 0;
2931
2932 int value = 0;
2933 value = r.GetAsInt(1);
2934 return value;
2935 }
2936
2937 /**
2938 *This is used for retrieving local setup keys of type binary. For more information, see Defines section in the skype-embedded_2.h <br>
2939 * @param key
2940 * @return value
2941 */
2942 public byte[] GetBin( String key) {
2943
2944 Request request = null;
2945 try {
2946 request = new XCallRequest(0,122);
2947 } catch (IOException e) {
2948 e.printStackTrace();
2949 if (errorListener != null)
2950 errorListener.OnSkypeKitFatalError();
2951 }
2952 request.addParm('S',1,key);
2953
2954 Response r = XCall((XCallRequest)request);
2955
2956 if (r.isErrCall())
2957 return null;
2958
2959 byte[] value = null;
2960 value = r.GetAsBinary(1);
2961 return value;
2962 }
2963
2964 /**
2965 *This is used for setting local setup keys of type string. For more information, see Defines section in the skype-embedded_2.h <br>
2966 * @param key
2967 * @param value
2968 */
2969 public void SetStr( String key, String value) {
2970
2971 Request request = null;
2972 try {
2973 request = new XCallRequest(0,123);
2974 } catch (IOException e) {
2975 e.printStackTrace();
2976 if (errorListener != null)
2977 errorListener.OnSkypeKitFatalError();
2978 }
2979 request.addParm('S',1,key);
2980 request.addParm('S',2,value);
2981
2982 XCall((XCallRequest)request);
2983 }
2984
2985 /**
2986 *This is used for setting local setup keys of type int. For more information, see Defines section in the skype-embedded_2.h <br>
2987 * @param key
2988 * @param value
2989 */
2990 public void SetInt( String key, int value) {
2991
2992 Request request = null;
2993 try {
2994 request = new XCallRequest(0,124);
2995 } catch (IOException e) {
2996 e.printStackTrace();
2997 if (errorListener != null)
2998 errorListener.OnSkypeKitFatalError();
2999 }
3000 request.addParm('S',1,key);
3001 request.addParm('i',2,value);
3002
3003 XCall((XCallRequest)request);
3004 }
3005
3006 /**
3007 *This is used for setting local setup keys of type binary. For more information, see Defines section in the skype-embedded_2.h <br>
3008 * @param key
3009 * @param value
3010 */
3011 public void SetBin( String key, byte[] value) {
3012
3013 Request request = null;
3014 try {
3015 request = new XCallRequest(0,125);
3016 } catch (IOException e) {
3017 e.printStackTrace();
3018 if (errorListener != null)
3019 errorListener.OnSkypeKitFatalError();
3020 }
3021 request.addParm('S',1,key);
3022 request.addParm('B',2,value);
3023
3024 XCall((XCallRequest)request);
3025 }
3026
3027 /**
3028 *Returns true if the given setup key is defined in local setup. For more information, see Defines section in the skype-embedded_2.h <br>
3029 * @param key
3030 * @return value
3031 */
3032 public boolean IsDefined( String key) {
3033
3034 Request request = null;
3035 try {
3036 request = new XCallRequest(0,126);
3037 } catch (IOException e) {
3038 e.printStackTrace();
3039 if (errorListener != null)
3040 errorListener.OnSkypeKitFatalError();
3041 }
3042 request.addParm('S',1,key);
3043
3044 Response r = XCall((XCallRequest)request);
3045
3046 if (r.isErrCall())
3047 return false;
3048
3049 boolean value = false;
3050 value = r.GetAsBoolean(1);
3051 return value;
3052 }
3053
3054 /**
3055 * @param key
3056 */
3057 public void Delete( String key) {
3058
3059 Request request = null;
3060 try {
3061 request = new XCallRequest(0,127);
3062 } catch (IOException e) {
3063 e.printStackTrace();
3064 if (errorListener != null)
3065 errorListener.OnSkypeKitFatalError();
3066 }
3067 request.addParm('S',1,key);
3068
3069 XCall((XCallRequest)request);
3070 }
3071
3072 /**
3073 * @param key
3074 * @return value
3075 */
3076 public String [] GetSubKeys( String key) {
3077
3078 Request request = null;
3079 try {
3080 request = new XCallRequest(0,128);
3081 } catch (IOException e) {
3082 e.printStackTrace();
3083 if (errorListener != null)
3084 errorListener.OnSkypeKitFatalError();
3085 }
3086 request.addParm('S',1,key);
3087
3088 Response r = XCall((XCallRequest)request);
3089
3090 if (r.isErrCall())
3091 return null;
3092
3093 Vector<String> value = new Vector<String>();
3094 while (r.HasMore(1))
3095 {
3096 String string = null;
3097 string = r.GetAsString(1);
3098 value.add(string);
3099 }
3100 return value.toArray(new String[value.size()]);
3101
3102 }
3103
3104 /**
3105 *Returns two string lists. First of them will contain list of two-letter language codes (ISO 639-1) The second list contains names of corresponding languages. <br>
3106 * @return GetISOLanguageInfoResult
3107 */
3108 public GetISOLanguageInfoResult GetISOLanguageInfo() {
3109
3110 Request request = null;
3111 try {
3112 request = new XCallRequest(0,207);
3113 } catch (IOException e) {
3114 e.printStackTrace();
3115 if (errorListener != null)
3116 errorListener.OnSkypeKitFatalError();
3117 }
3118
3119 Response r = XCall((XCallRequest)request);
3120
3121 if (r.isErrCall())
3122 return null;
3123
3124 GetISOLanguageInfoResult result = new GetISOLanguageInfoResult();
3125
3126 Vector<String> languageCodeList = new Vector<String>();
3127 while (r.HasMore(1))
3128 {
3129 String string = null;
3130 string = r.GetAsString(1);
3131 languageCodeList.add(string);
3132 }
3133 result.languageCodeList = languageCodeList.toArray(new String[languageCodeList.size()]);
3134
3135 Vector<String> languageNameList = new Vector<String>();
3136 while (r.HasMore(2))
3137 {
3138 String string = null;
3139 string = r.GetAsString(2);
3140 languageNameList.add(string);
3141 }
3142 result.languageNameList = languageNameList.toArray(new String[languageNameList.size()]);
3143
3144 return result;
3145 }
3146
3147 public class GetISOLanguageInfoResult {
3148 public String [] languageCodeList;
3149 public String [] languageNameList; /** assumes UI has set correct language */
3150 }
3151
3152 /**
3153 *Returns three string lists and one int array, containing 2-letter country code, country name, dialing prefix and example dial string (not available for all items). This method does currently return 0 for South Georgia and the South Sandwich Islands. <br>
3154 * @return GetISOCountryInfoResult
3155 */
3156 public GetISOCountryInfoResult GetISOCountryInfo() {
3157
3158 Request request = null;
3159 try {
3160 request = new XCallRequest(0,208);
3161 } catch (IOException e) {
3162 e.printStackTrace();
3163 if (errorListener != null)
3164 errorListener.OnSkypeKitFatalError();
3165 }
3166
3167 Response r = XCall((XCallRequest)request);
3168
3169 if (r.isErrCall())
3170 return null;
3171
3172 GetISOCountryInfoResult result = new GetISOCountryInfoResult();
3173
3174 Vector<String> countryCodeList = new Vector<String>();
3175 while (r.HasMore(1))
3176 {
3177 String string = null;
3178 string = r.GetAsString(1);
3179 countryCodeList.add(string);
3180 }
3181 result.countryCodeList = countryCodeList.toArray(new String[countryCodeList.size()]);
3182
3183 Vector<String> countryNameList = new Vector<String>();
3184 while (r.HasMore(2))
3185 {
3186 String string = null;
3187 string = r.GetAsString(2);
3188 countryNameList.add(string);
3189 }
3190 result.countryNameList = countryNameList.toArray(new String[countryNameList.size()]);
3191
3192 Vector<Integer> countryPrefixList = new Vector<Integer>();
3193 while (r.HasMore(3))
3194 {
3195 Integer integer = null;
3196 integer = new Integer(r.GetAsInt(3));
3197 countryPrefixList.add(integer);
3198 }
3199
3200 int[] intArray = new int[countryPrefixList.size()];
3201 for (int i = 0; i < countryPrefixList.size(); i++) {
3202 intArray[i] = countryPrefixList.get(i);
3203 }
3204 result.countryPrefixList = intArray;
3205 Vector<String> countryDialExampleList = new Vector<String>();
3206 while (r.HasMore(4))
3207 {
3208 String string = null;
3209 string = r.GetAsString(4);
3210 countryDialExampleList.add(string);
3211 }
3212 result.countryDialExampleList = countryDialExampleList.toArray(new String[countryDialExampleList.size()]);
3213
3214 return result;
3215 }
3216
3217 public class GetISOCountryInfoResult {
3218 public String [] countryCodeList;
3219 public String [] countryNameList; /** assumes UI has set correct language */
3220 public int [] countryPrefixList;
3221 public String [] countryDialExampleList;
3222 }
3223
3224 /**
3225 *Returns 2-letter country code based on PSTN number. The input argument has to be without + in from of it - '37212345678' will return 'ee' while '+37212345678' will return an empty string. <br>
3226 * @param number
3227 * @return countryCode
3228 */
3229 public String GetISOCountryCodebyPhoneNo( String number) {
3230
3231 Request request = null;
3232 try {
3233 request = new XCallRequest(0,211);
3234 } catch (IOException e) {
3235 e.printStackTrace();
3236 if (errorListener != null)
3237 errorListener.OnSkypeKitFatalError();
3238 }
3239 request.addParm('S',1,number);
3240
3241 Response r = XCall((XCallRequest)request);
3242
3243 if (r.isErrCall())
3244 return null;
3245
3246 String countryCode = null;
3247 countryCode = r.GetAsString(1);
3248 return countryCode;
3249 }
3250
3251
3252 }