public static string GetSkypeUserDisplayName(SKYPE4COMLib.User user) { if (string.IsNullOrEmpty(user.DisplayName)) { return user.FullName; } else { return user.DisplayName; } }
public Chat_Message(SKYPE4COMLib.ChatMessage chatMessage) { _chatMessage = chatMessage; }
private void Skype_MessageStatus(SKYPE4COMLib.ChatMessage pMessage, SKYPE4COMLib.TChatMessageStatus Status) { if (SKYPE4COMLib.TChatMessageStatus.cmsSending == Status) return; if (SKYPE4COMLib.TChatMessageStatus.cmsReceived == Status) { if (File.Exists(so_ConfigPath)) { XElement node = XElement.Load(so_ConfigPath); IEnumerable<SkypeClass> query = (from item in node.Elements("Operator") select new SkypeClass(item.Element("Keyword").Value, item.Element("Reply").Value)); foreach (SkypeClass data in query) { if (data.Keyword != pMessage.Body) continue; if (checkBox1.CheckState == CheckState.Checked) { pMessage.Chat.SendMessage(textBox1.Text); AddLogs(pMessage.ChatName, pMessage.Body, textBox1.Text); } else { if (data.Reply != so_CacheMessage) { so_CacheMessage = data.Reply; pMessage.Chat.SendMessage(data.Reply); AddLogs(pMessage.ChatName, pMessage.Body, data.Reply); } } break; } } } }
/// <summary> /// チャットの既存メッセージを取得 /// </summary> private String getMessages(SKYPE4COMLib.Chat chat) { try { String str = ""; foreach (SKYPE4COMLib.ChatMessage msg in chat.Messages) { str += getMessageString(msg);//適当に整形 } return str; } catch (Exception) { return ""; } }
public Client(SKYPE4COMLib.Client client) { _client = client; }
private void AttachEventHandlers(SKYPE4COMLib.Skype skype) { var evt = (_ISkypeEvents_Event)skype; evt.ApplicationConnecting += this.Skype_ApplicationConnecting; evt.ApplicationDatagram += this.Skype_ApplicationDatagram; evt.ApplicationReceiving += this.Skype_ApplicationReceiving; evt.ApplicationSending += this.Skype_ApplicationSending; evt.ApplicationStreams += this.Skype_ApplicationStreams; evt.AsyncSearchUsersFinished += this.Skype_AsyncSearchUsersFinished; evt.AttachmentStatus += this.Skype_AttachmentStatus; evt.AutoAway += this.Skype_AutoAway; evt.CallDtmfReceived += this.Skype_CallDtmfReceived; evt.CallHistory += this.Skype_CallHistory; evt.CallInputStatusChanged += this.Skype_CallInputStatusChanged; evt.CallSeenStatusChanged += this.Skype_CallSeenStatusChanged; evt.CallStatus += this.Skype_CallStatus; evt.CallTransferStatusChanged += this.Skype_CallTransferStatusChanged; evt.CallVideoReceiveStatusChanged += this.Skype_CallVideoReceiveStatusChanged; evt.CallVideoSendStatusChanged += this.Skype_CallVideoSendStatusChanged; evt.CallVideoStatusChanged += this.Skype_CallVideoStatusChanged; evt.ChatMembersChanged += this.Skype_ChatMembersChanged; evt.ChatMemberRoleChanged += this.Skype_ChatMemberRoleChanged; evt.Command += this.Skype_Command; evt.ConnectionStatus += this.Skype_ConnectionStatus; evt.ContactsFocused += this.Skype_ContactsFocused; evt.Error += this.Skype_Error; evt.FileTransferStatusChanged += this.Skype_FileTransferStatusChanged; evt.GroupDeleted += this.Skype_GroupDeleted; evt.GroupExpanded += this.Skype_GroupExpanded; evt.GroupUsers += this.Skype_GroupUsers; evt.GroupVisible += this.Skype_GroupVisible; evt.MessageHistory += this.Skype_MessageHistory; evt.MessageStatus += this.Skype_MessageStatus; evt.Mute += this.Skype_Mute; evt.OnlineStatus += this.Skype_OnlineStatus; evt.PluginEventClicked += this.Skype_PluginEventClicked; evt.PluginMenuItemClicked += this.Skype_PluginMenuItemClicked; evt.Reply += this.Skype_Reply; evt.SilentModeStatusChanged += this.Skype_SilentModeStatusChanged; evt.SmsMessageStatusChanged += this.Skype_SmsMessageStatusChanged; evt.SmsTargetStatusChanged += this.Skype_SmsTargetStatusChanged; evt.UILanguageChanged += this.Skype_UILanguageChanged; evt.UserAuthorizationRequestReceived += this.Skype_UserAuthorizationRequestReceived; evt.UserMood += this.Skype_UserMood; evt.UserStatus += this.Skype_UserStatus; evt.VoicemailStatus += this.Skype_VoicemailStatus; evt.WallpaperChanged += this.Skype_WallpaperChanged; }
private void Skype_ApplicationStreams(SKYPE4COMLib.Application application, ApplicationStreamCollection applicationstreamcollection) { this.Logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name); }
/// <summary> /// Handles the Skype API ApplicationConnecting event. /// </summary> private void ApplicationConnecting(SKYPE4COMLib.Application pApp, UserCollection pUsers) { // TODO: are states correct? Logger.Info("Connecting: " + pApp.Name + ":: "); for(int i = 1; i <= pUsers.Count; ++i) { Logger.Info(pUsers[i].Handle + " "); } if (pUsers.Count == 1) { Logger.Info("Connecting..."); } if (pUsers.Count == 0) { Logger.Info("Waiting for accept..."); } }
private void Skype_ApplicationConnecting(SKYPE4COMLib.Application application, UserCollection usercollection) { this.Logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name); }
public Chat(SKYPE4COMLib.Chat chat, string name) { Name = name; _chat = chat; }
/// <summary> /// Change status message /// </summary> /// <remarks> /// Chat messages /// </remarks> /// <param name="chatmessage">talk to person (always) one person</param> /// <param name="status">status of talk</param> private void ChangeMessageStatus(SKYPE4COMLib.ChatMessage chatmessage, SKYPE4COMLib.TChatMessageStatus status) { try { //chat receive if ((status == TChatMessageStatus.cmsReceived) && (chatmessage.Type == TChatMessageType.cmeSaid)) { List<string> listOfRecipients = new List<string>(); if (chatmessage.Chat.Type == TChatType.chatTypeMultiChat) { //conferenc talk > 2 users UserCollection collectionOfUsers = chatmessage.Chat.Members as UserCollection; foreach (User oneUser in collectionOfUsers) { listOfRecipients.Add(oneUser.Handle); } } else { //pair talk < 3 users listOfRecipients.Add(skype.CurrentUser.Handle); } ChatMessage receiveChatMessage = new ChatMessage(chatmessage.FromHandle, listOfRecipients, chatmessage.Body, chatmessage.Timestamp, chatmessage.Chat.Blob); interfaceToOperate.AddMessage(receiveChatMessage, TypeConversation.Chat); } //chat send else if ((status == TChatMessageStatus.cmsSending) && (chatmessage.Type == TChatMessageType.cmeSaid)) { List<string> listOfRecipients = new List<string>(); string recipient = string.Empty; if (chatmessage.Chat.Type == TChatType.chatTypeMultiChat) { //conferenc talk > 2 users UserCollection collectOfUsers = chatmessage.Chat.Members as UserCollection; foreach (User oneUser in collectOfUsers) { if (oneUser.Handle != skype.CurrentUser.Handle) { //if itsn't me listOfRecipients.Add(oneUser.Handle); } } } else { //talk in one person recipient = chatmessage.Chat.DialogPartner; listOfRecipients.Add(recipient); } ChatMessage receiveChatMessage = new ChatMessage(chatmessage.FromHandle, listOfRecipients, chatmessage.Body, chatmessage.Timestamp, chatmessage.Chat.Blob); interfaceToOperate.AddMessage(receiveChatMessage, TypeConversation.Chat); } } catch (Exception ex) { ErrorCode = ex.Message; } }
public User(SKYPE4COMLib.User user) { _user = user; }
/// <summary> /// Handles the Skype API ApplicationStreams event /// </summary> private void ApplicationStreams(SKYPE4COMLib.Application pApp, ApplicationStreamCollection pStreams) { if (pApp.Name != Application.Name) return; foreach(ApplicationStream stream in pStreams) { Console.WriteLine(stream.PartnerHandle + "::" + stream.Handle); if (streams.ContainsKey(stream.PartnerHandle)) { Logger.Info(string.Format("New connection to {0} replaces old one.", pStreams[1].PartnerHandle)); } else { connections[stream.PartnerHandle] = new Dictionary<int, SkypeConnection>(); } streams[stream.PartnerHandle] = stream; } Console.WriteLine(); Console.WriteLine("--"); }
/// <summary> /// Handles the Skype API ApplicationReceiving event. /// </summary> private void ApplicationReceiving(SKYPE4COMLib.Application pApp, ApplicationStreamCollection pStreams) { // TODO: move GUI code out of here if (pStreams.Count == 0) return; if (pStreams[1].DataLength == 0) return; string text = pStreams[1].Read(); // Decode message try { byte[] both = Convert.FromBase64String(text); int connectionId = BitConverter.ToInt32(both, 0); object message = NetUtils.Deserialize(both, 4, both.Length-4); string partner = pStreams[1].PartnerHandle; if (connectionId == ApplicationConnectionId) { // Received a sharing invitation: // the user might now either accept or reject the invitation // and we'll have to notify the host about his choice. if (message is SharingInvitationMessage) { SharingInvitationMessage sharingInvitation = (SharingInvitationMessage)message; text = string.Format("You received an invitation from {0} via Skype to share document {1}. Would you like to accept?", partner, sharingInvitation.DocumentName); var result = MessageBox.Show(text, "Invitation", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { SkypeConnection connection = Connect(partner, 1000); connection.OutgoingChannel = sharingInvitation.Channel; OnJoinSession(new JoinSessionEventArgs(connection)); Send(partner, 0, new AcceptSharingInvitationMessage(sharingInvitation.InvitationId, connection.IncomingChannel)); } else { Send(partner, 0, new DeclineSharingInvitationMessage(sharingInvitation.InvitationId)); } } // Another user has accepted a sharing invitation else if (message is AcceptSharingInvitationMessage) { AcceptSharingInvitationMessage accept = (AcceptSharingInvitationMessage)message; if (!invitations.ContainsKey(accept.InvitationId)) { Logger.Error(string.Format("Received {0} but no such invitation was sent.", message)); return; } SharingInvitationMessage sharingInvitation = invitations[accept.InvitationId]; if (sharingInvitation.InvitedUser != partner) { Logger.Error(string.Format("{0} accepted {1} intended for {2}", partner, sharingInvitation, sharingInvitation.InvitedUser)); return; } SkypeConnection connection = invitationChannels[accept.InvitationId]; ISynchronizationSession session = invitationSessions[accept.InvitationId]; invitations.Remove(accept.InvitationId); invitationChannels.Remove(accept.InvitationId); invitationSessions.Remove(accept.InvitationId); // Start the session! connection.OutgoingChannel = accept.Channel; OnHostSession(new HostSessionEventArgs(session, connection)); } // Another user has rejected a sharing invitation else if (message is DeclineSharingInvitationMessage) { DeclineSharingInvitationMessage decline = (DeclineSharingInvitationMessage)message; if (!invitations.ContainsKey(decline.InvitationId)) { Logger.Error(string.Format("Received {0} but no such invitation was sent.", message)); return; } SharingInvitationMessage sharingInvitation = invitations[decline.InvitationId]; if (sharingInvitation.InvitedUser != partner) { Logger.Error(string.Format("{0} rejected {1} intended for {2}", partner, sharingInvitation, sharingInvitation.InvitedUser)); } invitations.Remove(decline.InvitationId); invitationChannels.Remove(decline.InvitationId); invitationSessions.Remove(decline.InvitationId); MessageBox.Show("Invitation was rejected"); } } else { connections[pStreams[1].PartnerHandle][connectionId].ReceiveMessage(new ReceivedEventArgs(message)); } } catch(Exception e) { Console.Error.WriteLine("Receive error: {0}", e); Logger.Error("Received ill-formed skype datagram", e); } }
private void Skype_ApplicationDatagram(SKYPE4COMLib.Application application, ApplicationStream applicationstream, String itext) { this.Logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name); }
public UserCollection(SKYPE4COMLib.UserCollection userCollection) { _userCollection = userCollection; }
// This syntax can be used to remove ambiguity which would occur if we used just Application // vs SKYPE4COMLib.Application. public void OurApplicationStreams(SKYPE4COMLib.Application application, ApplicationStreamCollection applicationstreamcollection) { // Always use try/catch with ANY Skype calls. try { // Write Applcation Streams to Window. AddTextToTextBox1(DateTime.Now.ToLocalTime() + ": " + "Application Streams: " + application.Name + " - Application Stream Collection Count: " + applicationstreamcollection.Count + "\r\n"); } catch (Exception e) { // Possibly old Skype4COM version, log an error, drop into debug if wanted. AddTextToTextBox1(DateTime.Now.ToLocalTime() + ": " + "Application Streams Event Fired - Bad Text " + " - Exception Source: " + e.Source + " - Exception Message: " + e.Message + "\r\n"); // If the "Use Auto Debug" check box is checked and we are in debug, drop into debug here when retry, otherwise, prompt for action. Debug.Assert(!this.UseAutoDebug.Checked); } }