Пример #1
0
        public void OnReceiveTalkMessage( System.Object talk_friend , System.String data )
        {
            Log.Debug("Received Talk Message");
            try
            {
                IGoogleDesktopTalkFriend friend = (IGoogleDesktopTalkFriend)talk_friend;
                String[] cmd = data.Split('|');
                String game = cmd[0];
                String ip = cmd[1];
                int port = Int32.Parse(cmd[2]);

                String msg = String.Format(lang.getValue("talkInvite")+"\n",
                                                friend.name, game, ip, port);
                Log.Debug("Received Invitation for "+game+" on "+ip+":"+port+" from "+friend.name);
                RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Imagine Interactive\Gameserver Panel\Games\"+game);
                if (key == null)
                {
                    msg += String.Format( lang.getValue("talkUnknownGame"), pluginName);
                    MessageBox.Show(msg, pluginName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (key.GetValue("isInstalled").ToString() == "0")
                {
                    findGames();
                    if (key.GetValue("isInstalled").ToString() == "0")
                    {
                        msg += lang.getValue("talkGameNotInstalled");
                        MessageBox.Show(msg, pluginName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
                msg += lang.getValue("talkConnect");
                key.Close();

                Log.Debug("Displaying Notification");
                GameserverContentItem item = new GameserverContentItem();
                IGoogleDesktopDisplayContentItemHelper itemHelper = (IGoogleDesktopDisplayContentItemHelper)item;
                GoogleDesktopDisplayContentItemLayout contentLayout =
                    GoogleDesktopDisplayContentItemLayout.GDD_CONTENT_ITEM_LAYOUT_NOWRAP_ITEMS;
                GoogleDesktopDisplayContentItemFlags itemFlags =
                    GoogleDesktopDisplayContentItemFlags.GDD_CONTENT_ITEM_FLAG_NONE;
                itemHelper.heading = msg;
                itemHelper.tooltip = msg;
                itemHelper.source = "0,0,0";
                itemHelper.snippet = data;
                itemHelper.flags = itemFlags;
                itemHelper.open_command = this;
                itemHelper.layout = contentLayout;

                GoogleDesktopDisplayUINotificationClass notify = new GoogleDesktopDisplayLib.GoogleDesktopDisplayUINotificationClass();
                notify.enabled = true;
                notify.AddNotification(controlGuid, item);
            }
            catch (Exception E)
            {
                Log.Error("onReceiveTalkMessage: "+E.Message);
            }
            Log.Debug("Executed Talk Message");
        }