示例#1
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems)
        {
            string number;

            Item item = items.First();

            if (item is ITextItem)
            {
                number = Skype.StripPhoneChars((item as ITextItem).Text);
                if (!number.StartsWith("+"))
                {
                    number = string.Format("+{0}", number);
                }
                Skype.Call(number);
            }
            else if (item is SkypeContactDetailItem)
            {
                Skype.Call((item  as SkypeContactDetailItem).Handle);
            }
            else if (item is ContactItem)
            {
                Skype.Call(item as ContactItem);
            }
            else if (item is IContactDetailItem)
            {
                number = Skype.StripPhoneChars((item as IContactDetailItem).Description);
                if (!number.StartsWith("+"))
                {
                    number = string.Format("+{0}", number);
                }
                Skype.Call(number);
            }
            yield break;
        }
示例#2
0
        public override bool SupportsItem(Item item)
        {
            if (item is ITextItem)
            {
                return(Regex.Match(Skype.StripPhoneChars((item as ITextItem).Text), "^[+]?\\d*$").Success);
            }
            if (item is ContactItem)
            {
                return(null != (item as ContactItem) ["handle.skype"]);
            }
            if (item is SkypeContactDetailItem)
            {
                return(true);
            }
            if (item is IContactDetailItem)
            {
                IContactDetailItem detail = (item as IContactDetailItem);
                if (detail.Key.Contains("phone"))
                {
                    return(true);
                }

                return(Regex.Match(Skype.StripPhoneChars(detail.Description), "^[+]?\\d*$").Success);
            }
            return(false);
        }
示例#3
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems)
        {
            StatusItem status = (items.First() as StatusItem);

            if (Skype.InstanceIsRunning)
            {
                Skype.SetStatus(status);
            }
            yield break;
        }
示例#4
0
        public static void Configure(Dictionary <string, string> dict)
        {
            var skype = new Skype(dict["path"]);

            skype.OnMessage += msg =>
            {
                if (evt != null)
                {
                    evt("[skype " + msg.Sender + "] " + msg.Text, 0);
                }
            };
        }
示例#5
0
 public override IEnumerable <Item> ChildrenOfItem(Item item)
 {
     if (Skype.IsSkype(item))
     {
         yield return(new SkypeBrowseStatusItem());
     }
     else if (item is SkypeBrowseStatusItem)
     {
         foreach (Item status in statuses)
         {
             yield return(status);
         }
     }
 }
示例#6
0
 public SkypeContactDetailItem(ContactItem owner, string handle)
 {
     this.Handle = handle;
     this.status = Skype.ContactStatus(this.Handle);
     //if offline was returned, query to see if the user has a phone number set, maybe the user's status is really "SKYPEOUT"
     if (this.status == Skype.Statuses [OnlineStatus.Offline])
     {
         foreach (string detail in owner.Details.Where(d => d.Contains("phone")))
         {
             Console.WriteLine("Checking {0} :: {1}", detail, owner [detail]);
             if (Skype.ContactStatus(Skype.StripPhoneChars(owner [detail])) == Skype.Statuses [OnlineStatus.SkypeOut])
             {
                 this.status = Skype.Statuses [OnlineStatus.SkypeOut];
             }
         }
     }
 }
示例#7
0
        private ContactItem CreateContact(string handle)
        {
            string contactName;

            contactName = (string.IsNullOrEmpty(Skype.ContactDisplayName(handle))) ?
                          (string.IsNullOrEmpty(Skype.ContactFullName(handle))) ?
                          handle : Skype.ContactFullName(handle) :
                          Skype.ContactDisplayName(handle);

            ContactItem contact = ContactItem.Create(contactName);

            MaybeAddDetail(contact, "handle", handle);

            MaybeAddDetail(contact, "phone.home", Skype.ContactHomePhone(handle));
            MaybeAddDetail(contact, "phone.mobile", Skype.ContactMobilePhone(handle));
            MaybeAddDetail(contact, "phone.work", Skype.ContactOfficePhone(handle));

            return(contact);
        }
示例#8
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems)
        {
            Item   user    = items.First();
            string message = "";

            if (modItems.Any())
            {
                message = (modItems.First() as ITextItem).Text;
            }

            if (user is ContactItem)
            {
                Skype.ChatWith((user as ContactItem) ["handle.skype"], message);
                yield break;
            }
            else if (user is SkypeContactDetailItem)
            {
                Skype.ChatWith((user as SkypeContactDetailItem).Handle, message);
                yield break;
            }
            yield break;
        }
示例#9
0
        public static void Call(string request)
        {
            if (!Skype.InstanceIsRunning)
            {
                Log <Skype> .Debug("Starting Skype.");

                Skype.StartIfNecessary();
            }

            if (SkypeObject == null)
            {
                TryGetSkypeObject();
                if (SkypeObject == null)
                {
                    return;
                }
            }

            Log <Skype> .Debug("Calling {0}", request);

            SkypeObject.Invoke(string.Format("CALL {0}", request));
        }
示例#10
0
        public override IEnumerable <Item> ChildrenOfItem(Item item)
        {
            if (Skype.IsSkype(item))
            {
                yield return(new SkypeBrowseBuddyItem());
            }
            else if (item is SkypeBrowseBuddyItem)
            {
                foreach (ContactItem contact in contacts)
                {
                    yield return(contact);
                }
            }
            else if (item is ContactItem)
            {
                ContactItem contact = item as ContactItem;

                foreach (string detail in contact.Details)
                {
                    if (!detail.EndsWith(".skype"))
                    {
                        continue;
                    }

                    if (detail.StartsWith("handle"))
                    {
                        yield return(new SkypeContactDetailItem(contact, contact ["handle.skype"]));
                    }
                    else if (detail.StartsWith("phone"))
                    {
                        yield return(new PhoneContactDetailItem(contact, detail));
                    }
                }
            }
            yield break;
        }
示例#11
0
 public static string ContactHomePhone(string handle)
 {
     return(Skype.Get("USER {0} PHONE_HOME", handle));
 }
示例#12
0
 public static StatusItem ContactStatus(string handle)
 {
     return(Statuses.Values.FirstOrDefault(s => s.Code == Skype.Get("USER {0} ONLINESTATUS", handle)) ??
            Statuses [OnlineStatus.Unknown]);
 }
示例#13
0
 public static string ContactFullName(string handle)
 {
     return(Skype.Get("USER {0} FULLNAME", handle));
 }
示例#14
0
 public static void Call(ContactItem contact)
 {
     Skype.Call(contact ["handle.skype"]);
 }
示例#15
0
 public static string ContactMobilePhone(string handle)
 {
     return(Skype.Get("USER {0} PHONE_MOBILE", handle));
 }
示例#16
0
 public static string ContactOfficePhone(string handle)
 {
     return(Skype.Get("USER {0} PHONE_OFFICE", handle));
 }
示例#17
0
 public static string ContactDisplayName(string handle)
 {
     return(Skype.Get("USER {0} DISPLAYNAME", handle));
 }
示例#18
0
 public static string ContactMood(string handle)
 {
     return(Skype.Get("USER {0} MOOD_TEXT", handle));
 }