Beispiel #1
0
 public PidginHandleContactDetailItem(string proto, string handle, string custom_icon)
 {
     this.proto       = proto;
     this.handle      = handle;
     this.custom_icon = custom_icon;
     this.online      = (Pidgin.BuddyIsOnline(handle)) ? AddinManager.CurrentLocalizer.GetString("Online") : AddinManager.CurrentLocalizer.GetString("Offline");
 }
Beispiel #2
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems)
        {
            List <string> names   = new List <string> ();
            string        message = "";

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

            foreach (Item item in items)
            {
                if (item is ContactItem)
                {
                    // Just grab the first protocol we see.
                    ContactItem contact = item as ContactItem;
                    foreach (string detail in contact.Details)
                    {
                        if (!detail.StartsWith("prpl-"))
                        {
                            continue;
                        }
                        //if this buddy is online, add and break
                        if (Pidgin.BuddyIsOnline(contact[detail]))
                        {
                            names.Add(contact[detail]);
                            break;
                        }
                    }
                }
                else if (item is PidginHandleContactDetailItem)
                {
                    names.Add((item as PidginHandleContactDetailItem).Value);
                }
            }


            if (names.Count > 0)
            {
                Services.Application.RunOnThread(() => {
                    Pidgin.StartIfNeccessary();
                    Services.Application.RunOnMainThread(() => {
                        foreach (string name in names)
                        {
                            if (!string.IsNullOrEmpty(message))
                            {
                                Pidgin.OpenConversationWithBuddy(name, message);
                            }
                            else
                            {
                                Pidgin.OpenConversationWithBuddy(name);
                            }
                        }
                    });
                });
            }
            yield break;
        }
Beispiel #3
0
 public override bool SupportsItem(Item item)
 {
     if (item is ContactItem)
     {
         ContactItem contact = item as ContactItem;
         return(contact.Details.Where(d => Pidgin.BuddyIsOnline(contact[d])).Any());
     }
     return(true);
 }