Exemple #1
0
        void HandleActivityLinkClicked(QUrl url)
        {
            try {
                Uri uri = new Uri(url.ToString());
                if (uri.Scheme == "http" || uri.Scheme == "https")
                {
                    Util.Open(uri.ToString());
                }
                else
                {
                    if (uri.Scheme == "xmpp")
                    {
                        JID jid   = new JID(uri.AbsolutePath);
                        var query = XmppUriQueryInfo.ParseQuery(uri.Query);
                        switch (query.QueryType)
                        {
                        case "message":
                            // FIXME: Should not ask which account to use, should use whichever account generated the event.
                            var account = Gui.ShowAccountSelectMenu(this);
                            if (account != null)
                            {
                                Gui.TabbedChatsWindow.StartChat(account, jid);
                            }
                            break;

                        default:
                            throw new NotSupportedException("Unsupported query type: " + query.QueryType);
                        }
                    }
                    else if (uri.Scheme == "activity-item")
                    {
                        string itemId = uri.AbsolutePath;
                        string action = uri.Query.Substring(1);
                        m_ActivityFeedItems[itemId].TriggerAction(action);
                    }
                }
            } catch (Exception ex) {
                Console.Error.WriteLine(ex);
                QMessageBox.Critical(null, "Synapse Error", ex.Message);
            }
        }
        public void RequestUrl(Uri uri)
        {
            // FIXME: Actually we want to show this as a lightbox or something.
            LoadContent(uri, "Loading...");

            if (m_Account.ConnectionState != AccountConnectionState.Connected)
            {
                LoadContent(uri, "You are not connected.");
                return;
            }

            var info = XmppUriQueryInfo.ParseQuery(uri.Query);

            string queryType = info.QueryType;

            // Default to disco.
            if (String.IsNullOrEmpty(queryType))
            {
                queryType = "disco";
            }

            switch (queryType)
            {
            case "disco":
                var    jid  = new JID(uri.AbsolutePath);
                string node = null;
                if (info.Parameters.ContainsKey("node"))
                {
                    node = info.Parameters["node"];
                }
                var discoNode = new jabber.connection.DiscoNode(jid, node);
                m_Account.DiscoManager.BeginGetFeatures(discoNode, new DiscoNodeHandler(ReceivedFeatures), null);
                break;

            default:
                throw new Exception("Unsupported query type: " + queryType);
            }
        }