Exemple #1
0
        void LogSessionStart()
        {
            DoHistoryAction(manager =>
            {
                sessionLogged       = true;
                IBuddy primaryBuddy = Buddies.FirstOrDefault();
                var newSession      = new Session()
                {
                    Id          = session.Id.ToString(),
                    ContactId   = primaryBuddy.Id,
                    ContactName = primaryBuddy.DisplayName,
                    Start       = DateTime.Now
                };

                var participants = Buddies.Append(self)
                                   .Select(b => new Participant()
                {
                    Id          = Guid.NewGuid().ToString(),
                    ContactId   = b.Id,
                    ContactName = b.DisplayName,
                }).ToList();

                manager.AddSession(newSession, participants);
            });
        }
Exemple #2
0
 public void Invite(IBuddy buddy)
 {
     if (buddy != null && chatSession != null && !Buddies.Contains(buddy))
     {
         chatSession.Invite(buddy);
     }
 }
Exemple #3
0
        private void HandleConfig(String flap)
        {
            StringReader sr = new StringReader(flap);

            string group = string.Empty, buddyName = string.Empty;

            while (sr.Peek() != -1)
            {
                switch (sr.Read())
                {
                case 'g':
                    if (Protocol == ProtocolVersion.TOCv2)
                    {
                        sr.Read();
                    }
                    group = sr.ReadLine().Trim();
                    break;

                case 'b':
                    if (Protocol == ProtocolVersion.TOCv2)
                    {
                        sr.Read();
                    }
                    buddyName = sr.ReadLine().Trim();
                    Buddies.Add(new BuddyInfo(buddyName, group));
                    break;
                }
            }

            if (Config != null)
            {
                Config(this, EventArgs.Empty);
            }
        }
Exemple #4
0
        public void RemoveBuddy(string buddy)
        {
            _sw.WriteLine("REMOVE BUDDY {0}", buddy);
            _sw.Flush();

            Buddies.Remove(_buddyList.GetBuddy(buddy));
        }
Exemple #5
0
 void PrimaryBuddy_Online(object sender, EventArgs e)
 {
     Dispatcher.Invoke(() =>
     {
         if (!IsGroupChat && Buddies.Contains(PrimaryBuddy))
         {
             buddyOfflineMessage.Visibility = Visibility.Collapsed;
         }
     });
 }
Exemple #6
0
        void OnBuddyLeft(IBuddy buddy)
        {
            if (buddy == PrimaryBuddy && Buddies.Any())
            {
                PrimaryBuddy = Buddies.FirstOrDefault();
            }

            StopMonitoring(buddy);
            chatTextBox.AddInfo(String.Format("{0} " + Translation.Instance.ChatWindow_HasLeftConversation, buddy.DisplayName));
            OnParticipantsChanged();
        }
Exemple #7
0
 void chatClient_BuddyOnline(object sender, BuddyOnlineEventArgs e)
 {
     if (Buddies.Contains(e.Buddy))
     {
         OnContactListUpdated();
     }
     else
     {
         dispatcher.Invoke(() => Buddies.Add(e.Buddy));
     }
 }
Exemple #8
0
 void UpdateTitle()
 {
     if (IsBroadcastChat)
     {
         this.Title = Translation.Instance.ChatWindow_BroadCastChatTitle;
     }
     else
     {
         string title = String.Join(", ", Buddies.Select(b => b.DisplayName).ToArray());
         this.Title = String.IsNullOrEmpty(title) ? PrimaryBuddy.DisplayName : title;
     }
 }
Exemple #9
0
        void PrimaryBuddy_Offline(object sender, EventArgs e)
        {
            Dispatcher.Invoke(() =>
            {
                if (!IsGroupChat && Buddies.Contains(PrimaryBuddy))
                {
                    buddyOfflineMessage.DataContext = PrimaryBuddy.DisplayName;
                    buddyOfflineMessage.Visibility  = Visibility.Visible;

                    /* since ZeroMQ doesn't report failure and if the user comes online with new ip/port then existing
                     * session will continue to talk to old endpoint. Therefore destroy the session */
                    DestroySession();
                }
            });
        }
Exemple #10
0
        /// <summary>
        /// Sets the server configuration to match the contents of <see cref="Buddies"/>.
        /// </summary>
        public void SetConfig()
        {
            BuddyInfo[] buddies = Buddies.SortBuddyList();

            StringBuilder config = new StringBuilder();
            string        group  = null;

            foreach (BuddyInfo buddy in buddies)
            {
                if (group != buddy.Group)
                {
                    group = buddy.Group;
                    config.Append("g " + group + "\n");
                }
                config.Append("b " + buddy.ScreenName + "\n");
            }

            SendFlap(FrameType.Data, "toc_set_config \"" + config.ToString() + "\"");
        }
Exemple #11
0
        private void SendEmail_Click(object sender, RoutedEventArgs e)
        {
            string to = String.Join(";", Buddies.Select(buddy => buddy.Properties.EmailAddress).ToArray());

            System.Diagnostics.Process.Start("mailto:" + to);
        }
Exemple #12
0
        private void InviteContactMenu_Click(object sender, RoutedEventArgs e)
        {
            IEnumerable <Buddy> buddies = SquiggleUtility.SelectContacts(Translation.Instance.ChatWindow_InviteContact, this, b => Buddies.Contains(b));

            Invite(buddies);
        }