Beispiel #1
0
        void on_m_JoinChatButton_clicked()
        {
            Account selectedAccount = Gui.ShowAccountSelectMenu(m_JoinChatButton);

            if (selectedAccount != null)
            {
                JID    jid  = null;
                string nick = (!String.IsNullOrEmpty(mucNicknameLineEdit.Text)) ? mucNicknameLineEdit.Text : selectedAccount.ConferenceManager.DefaultNick;
                if (JID.TryParse(String.Format("{0}@{1}/{2}", mucRoomLineEdit.Text, mucServerLineEdit.Text, nick), out jid))
                {
                    if (!String.IsNullOrEmpty(jid.User) && !String.IsNullOrEmpty(jid.Server))
                    {
                        try {
                            selectedAccount.JoinMuc(jid, mucPasswordLineEdit.Text);
                        } catch (UserException ex) {
                            QMessageBox.Critical(this.TopLevelWidget(), "Synapse Error", ex.Message);
                        }
                    }
                    else
                    {
                        QMessageBox.Critical(null, "Synapse", "Invalid JID");
                    }
                }
                else
                {
                    QMessageBox.Critical(this.TopLevelWidget(), "Synapse Error", "Invalid conference room");
                }
            }
        }
Beispiel #2
0
        private void on_saveAccountButton_clicked()
        {
            JID jid = null;

            if (String.IsNullOrEmpty(m_LoginLineEdit.Text))
            {
                QMessageBox.Critical(this.TopLevelWidget(), "Synapse", "Login may not be empty.");
            }
            else if (!JID.TryParse(m_LoginLineEdit.Text, out jid))
            {
                QMessageBox.Critical(this.TopLevelWidget(), "Synapse", "Login should look like 'user@server'.");
            }
            else if (String.IsNullOrEmpty(new JID(m_LoginLineEdit.Text).User))
            {
                QMessageBox.Critical(this.TopLevelWidget(), "Synapse", "Login should look like 'user@server'.");
            }
            else if (String.IsNullOrEmpty(m_PasswordLineEdit.Text))
            {
                QMessageBox.Critical(this.TopLevelWidget(), "Synapse", "Password may not be empty");
            }
            else
            {
                var            accountInfo = new AccountInfo(jid.User, jid.Server, m_PasswordLineEdit.Text, "Synapse");
                AccountService service     = ServiceManager.Get <AccountService>();
                service.AddAccount(accountInfo);
            }
        }
Beispiel #3
0
    private void ShowDirChooser()
    {
        string new_root = QFileDialog.GetExistingDirectory(this,"Choose new path for beagle to index","/");

        if (new_root == null)
        {
            return;
        }
        Console.WriteLine("Selected new root '{0}'",new_root);

        // Check if the new_root is already part of some root in the list
        bool seen = false;

        for (int i = 0; i < main.RootsList.Count; ++i)
        {
            Console.WriteLine("Checking against {0}",main.RootsList.Item(i).Text());
            if (main.RootsList.Item(i).Text().StartsWith(new_root))
            {
                seen = true;
                QMessageBox.Critical(this,"Invalid directory","The selected path wasn't added. The list contains a path that is included in the new path.","OK");
            }
            else if (new_root.StartsWith(main.RootsList.Item(i).Text()))
            {
                seen = true;
                QMessageBox.Critical(this,"Invalid directory","The selected path wasn't added. The path is already included in one of the paths in the list.","OK");
            }
        }

        if (!seen)
        {
            main.RootsList.AddItem(new_root);
        }
    }
Beispiel #4
0
        void SendShout()
        {
            if (!String.IsNullOrEmpty(shoutLineEdit.Text))
            {
                List <IShoutHandler> selectedHandlers = new List <IShoutHandler>();

                for (int x = 0; x < shoutHandlersContainer.Layout().Count(); x++)
                {
                    var item = shoutHandlersContainer.Layout().ItemAt(x);
                    if (item is QWidgetItem)
                    {
                        var check = ((ShoutHandlerCheckBox)((QWidgetItem)item).Widget());
                        if (check.Checked)
                        {
                            selectedHandlers.Add(check.Handler);
                        }
                    }
                }

                try {
                    var service = ServiceManager.Get <ShoutService>();
                    service.Shout(shoutLineEdit.Text, selectedHandlers.ToArray());
                    shoutLineEdit.Clear();
                } catch (UserException ex) {
                    QMessageBox.Critical(base.TopLevelWidget(), "Synapse", ex.Message);
                }
            }
        }
Beispiel #5
0
    private void AddExcludeDir()
    {
        string dir = QFileDialog.GetExistingDirectory(this,"Select path to exclude",PathFinder.HomeDir);

        if (dir == null)
        {
            return;
        }
        Console.WriteLine("Excluding '{0}'",dir);

        // Check if the new dir is already part of some excluded directory in the list
        bool seen = false;

        for (int i = 0; i < main.ExcludeDirList.Count; ++i)
        {
            if (main.ExcludeDirList.Item(i).Text().StartsWith(dir))
            {
                seen = true;
                QMessageBox.Critical(this,"Invalid directory","The selected path wasn't added. The list contains a path that is included in the new path.","OK");
            }
            else if (dir.StartsWith(main.ExcludeDirList.Item(i).Text()))
            {
                seen = true;
                QMessageBox.Critical(this,"Invalid directory","The selected path wasn't added. The path is already included in one of the paths in the list.","OK");
            }
        }

        if (!seen)
        {
            main.ExcludeDirList.AddItem(dir);
        }
    }
 private void mRemoveButton_Clicked()
 {
     foreach (var index in mTableWidget.SelectionModel.SelectedRows())
     {
         try {
             var key = mTableWidget.Item(index.Row, 0)
                       .Data((int)Qt.ItemDataRole.UserRole) as ISshKey;
             mAgent.RemoveKey(key);
         } catch (AgentFailureException) {
             QMessageBox.Critical(this, Tr("Agent Failure"),
                                  Tr("Possible causes:") +
                                  "<ul>" +
                                  "<li>" + Tr("Agent is locked") + "</li>" +
                                  "<li>" + Tr("Key may have already been removed") + "</li>" +
                                  "</ul>"
                                  );
         } catch (Exception ex) {
             Debug.Fail(ex.ToString());
         }
     }
     if (mAgent is Agent)
     {
         UpdateUIState();
     }
     else
     {
         ReloadData();
     }
 }
Beispiel #7
0
        public override void Fail(string message, string detailMessage)
        {
            StackTrace       stack = new StackTrace();
            ManualResetEvent mutex = new ManualResetEvent(false);

            QApplication.Invoke(delegate {
                string msg = String.Format("{0}{1}{2}{1}{1}{3}", message, Environment.NewLine, detailMessage, stack);

                Console.Error.WriteLine("---");
                Console.Error.WriteLine("ASSERTION FAILED");
                Console.Error.WriteLine(msg);

                var result = QMessageBox.Critical(null, "Assertion Failed", msg,
                                                  (uint)QMessageBox.StandardButton.Abort |
                                                  (uint)QMessageBox.StandardButton.Ignore);

                if (result == Qyoto.QMessageBox.StandardButton.Abort)
                {
                    Thread.CurrentThread.Abort();
                }

                mutex.Set();
            });
            mutex.WaitOne();
        }
Beispiel #8
0
        void on_editAccountButton_clicked()
        {
            var selected = accountsList.SelectionModel().SelectedIndexes();

            if (selected.Count > 0)
            {
                var data = accountsList.Model().Data(selected[0], (int)Qt.ItemDataRole.DisplayRole);
                var jid  = new jabber.JID((string)data);

                var accountService = ServiceManager.Get <AccountService>();

                Account account = accountService.GetAccount(jid);
                if (account != null)
                {
                    if (!account.IsReadOnly)
                    {
                        var dialog = new EditAccountDialog(account.Info, this);
                        dialog.Show();
                        dialog.Exec();

                        accountsList.Update();
                    }
                    else
                    {
                        QMessageBox.Critical(this, "Error", "Cannot modify account while connected.");
                    }
                }
            }
        }
Beispiel #9
0
 void AddRosterItemComplete(object sender, jabber.protocol.client.IQ response, object data)
 {
     if (response.Type != jabber.protocol.client.IQType.set)
     {
         QApplication.Invoke(delegate {
             QMessageBox.Critical(Gui.MainWindow, "Failed to add octy", "Server returned an error.");
         });
     }
 }
Beispiel #10
0
 void AddRosterItemComplete(object sender, IQ response, object data)
 {
     if (response.Type == IQType.set)
     {
         QApplication.Invoke(delegate {
             Gui.MainWindow.HideLightbox();
         });
     }
     else
     {
         QApplication.Invoke(delegate {
             QMessageBox.Critical(base.TopLevelWidget(), "Failed to add user", "Server returned an error.");
         });
     }
 }
Beispiel #11
0
 /// <summary>
 /// Show Message Window
 /// </summary>
 public static void ShowMessage(QWidget parent, string title, string message, MessageType mt)
 {
     // Gui Message
     if (mt == MainClass.MessageType.Info)
     {
         QMessageBox.Information(parent, title, message);
     }
     else if (mt == MainClass.MessageType.Warning)
     {
         QMessageBox.Warning(parent, title, message);
     }
     else if (mt == MainClass.MessageType.Error)
     {
         QMessageBox.Critical(parent, title, message);
     }
 }
Beispiel #12
0
 void on_mucTree_activated(QModelIndex index)
 {
     if (index.IsValid())
     {
         if (index.InternalPointer() is BookmarkConference)
         {
             Account            account = (Account)index.Parent().InternalPointer();
             BookmarkConference conf    = (BookmarkConference)index.InternalPointer();
             try {
                 account.JoinMuc(conf.JID, conf.Password);
             } catch (UserException e) {
                 QMessageBox.Critical(this.TopLevelWidget(), "Synapse", e.Message);
             }
         }
     }
 }
Beispiel #13
0
        void HandleAddAccountButtonClicked()
        {
            bool error = false;
            JID  jid   = null;

            if (!JID.TryParse(jidLineEdit.Text, out jid))
            {
                QMessageBox.Critical(this, "Problem saving account", "JID is invalid");
                error = true;
            }
            else if (String.IsNullOrEmpty(jid.User))
            {
                QMessageBox.Critical(this, "Problem saving account", "JID must have a username");
                error = true;
            }
            else if (String.IsNullOrEmpty(jid.Server))
            {
                QMessageBox.Critical(this, "Problem saving account", "JID must have a server");
                error = true;
            }
            else if (passwordLineEdit.Text.Trim() == String.Empty)
            {
                QMessageBox.Critical(this, "Problem saving account", "Password may not be blank");
                error = true;
            }
            else if (resourceComboBox.CurrentText.Trim() == String.Empty)
            {
                QMessageBox.Critical(this, "Problem saving account", "Resource may not be blank");
                error = true;
            }

            if (error)
            {
                return;
            }

            var accountInfo = new AccountInfo(jid.User, jid.Server, passwordLineEdit.Text, resourceComboBox.CurrentText);

            accountInfo.AutoConnect = autoConnectCheckBox.Checked;
            ServiceManager.Get <AccountService>().AddAccount(accountInfo);

            base.Accept();
        }
Beispiel #14
0
        void on_buttonBox_clicked(QAbstractButton button)
        {
            try {
                var role = buttonBox.buttonRole(button);
                if (role == QDialogButtonBox.ButtonRole.AcceptRole)
                {
                    JID jid = new JID(jidLineEdit.Text);

                    // FIXME: Start spinner

                    m_Account.AddRosterItem(jid, nameLineEdit.Text, groupsWidget.SelectedGroups, AddRosterItemComplete);
                }
                else
                {
                    Gui.MainWindow.HideLightbox();
                }
            } catch (Exception ex) {
                QMessageBox.Critical(base.TopLevelWidget(), "Failed to add user", ex.Message);
            }
        }
Beispiel #15
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);
            }
        }
Beispiel #16
0
        public static Account ShowAccountSelectMenu(QWidget attachWidget)
        {
            AccountService accountService = ServiceManager.Get <AccountService>();

            if (accountService.ConnectedAccounts.Count == 0)
            {
                var widget = (attachWidget != null) ? attachWidget.TopLevelWidget() : Gui.MainWindow;
                QMessageBox.Critical(widget, "Synapse", "You are not connected.");
                return(null);
            }

            Account selectedAccount = null;

            if (accountService.ConnectedAccounts.Count > 1)
            {
                QMenu menu = new QMenu();
                menu.AddAction("Select Account:").SetDisabled(true);

                foreach (Account account in accountService.ConnectedAccounts)
                {
                    QAction action = menu.AddAction(account.Jid.ToString());
                    if (menu.ActiveAction() == null)
                    {
                        menu.SetActiveAction(action);
                    }
                }

                var     pos            = (attachWidget != null) ? attachWidget.MapToGlobal(new QPoint(0, attachWidget.Height())) : QCursor.Pos();
                QAction selectedAction = menu.Exec(pos);
                if (selectedAction != null)
                {
                    selectedAccount = accountService.GetAccount(new jabber.JID(selectedAction.Text));
                }
            }
            else
            {
                selectedAccount = accountService.ConnectedAccounts[0];
            }
            return(selectedAccount);
        }
Beispiel #17
0
 private void mUnlockButton_Clicked()
 {
     using (var dialog = new PassphraseDialog()) {
         dialog.Exec();
         if (dialog.Result == (int)QDialog.DialogCode.Rejected)
         {
             return;
         }
         var passphrase = dialog.GetPassphrase();
         try {
             mAgent.Unlock(passphrase);
         } catch (AgentLockedException) {
             QMessageBox.Critical(this, Tr("Error"), Tr("Agent is already locked"));
             Debug.Fail("Unlock button should have been disabled");
         } catch (AgentFailureException) {
             QMessageBox.Critical(this, Tr("Agent Failure"),
                                  Tr("Possible causes:") +
                                  "<ul>" +
                                  "<li>" + Tr("Passphrase was incorrect") + "</li>" +
                                  "<li>" + Tr("Agent is already unlocked") + "</li>" +
                                  "<li>" + Tr("Agent does not support locking") + "</li>" +
                                  "</ul>"
                                  );
         } catch (Exception ex) {
             Debug.Fail(ex.ToString());
         }
     }
     if (mAgent is Agent)
     {
         UpdateUIState();
     }
     else
     {
         ReloadData();
     }
 }
Beispiel #18
0
 private void mRemoveAllButton_Clicked()
 {
     try {
         mAgent.RemoveAllKeys();
     } catch (AgentFailureException) {
         QMessageBox.Critical(this, Tr("Agent Failure"),
                              Tr("Possible causes:") +
                              "<ul>" +
                              "<li>" + Tr("Agent is locked") + "</li>" +
                              "<li>" + Tr("Agent does not support removing all keys") + "</li>" +
                              "</ul>"
                              );
     } catch (Exception ex) {
         Debug.Fail(ex.ToString());
     }
     if (mAgent is Agent)
     {
         UpdateUIState();
     }
     else
     {
         ReloadData();
     }
 }
Beispiel #19
0
        public override void Accept()
        {
            bool error = false;
            JID  jid   = null;

            if (!JID.TryParse(jidLineEdit.Text, out jid))
            {
                QMessageBox.Critical(this, "Problem saving account", "JID is invalid");
                error = true;
            }
            else if (String.IsNullOrEmpty(jid.User))
            {
                QMessageBox.Critical(this, "Problem saving account", "JID must have a username");
                error = true;
            }
            else if (String.IsNullOrEmpty(jid.Server))
            {
                QMessageBox.Critical(this, "Problem saving account", "JID must have a server");
                error = true;
            }
            else if (passwordLineEdit.Text.Trim() == String.Empty)
            {
                QMessageBox.Critical(this, "Problem saving account", "Password may not be blank");
                error = true;
            }
            else if (resourceCombo.CurrentText.Trim() == String.Empty)
            {
                QMessageBox.Critical(this, "Problem saving account", "Resource may not be blank");
                error = true;
            }

            if (error)
            {
                return;
            }

            m_AccountInfo.User     = jid.User;
            m_AccountInfo.Domain   = jid.Server;
            m_AccountInfo.Password = passwordLineEdit.Text;
            m_AccountInfo.Resource = resourceCombo.CurrentText;

            m_AccountInfo.ConnectServer = serverLineEdit.Text;
            m_AccountInfo.ConnectPort   = portSpinBox.Value;

            m_AccountInfo.AutoConnect = autoConnectCheckBox.Checked;

            switch (comboBox.CurrentIndex)
            {
            case 0:
                m_AccountInfo.ProxyType = ProxyType.System;
                break;

            case 1:
                m_AccountInfo.ProxyType = ProxyType.None;
                break;

            case 2:
                m_AccountInfo.ProxyType = ProxyType.HTTP;
                break;

            case 3:
                m_AccountInfo.ProxyType = ProxyType.SOCKS4;
                break;

            case 4:
                m_AccountInfo.ProxyType = ProxyType.SOCKS5;
                break;
            }
            m_AccountInfo.ProxyHost     = proxyHostLineEdit.Text;
            m_AccountInfo.ProxyPort     = proxyPortSpinBox.Value;
            m_AccountInfo.ProxyUsername = proxyUserLineEdit.Text;
            m_AccountInfo.ProxyPassword = proxyPassLineEdit.Text;

            ServiceManager.Get <AccountService>().SaveAccounts();

            base.Accept();
        }
Beispiel #20
0
 private void ErrorButton_Clicked(bool obj)
 {
     QMessageBox.Critical(this, "Error", "This is Critical dialog!");
 }
Beispiel #21
0
 private void mAddButton_Clicked()
 {
     // TODO - persist start directory (and possibly viewMode)
     using (var dialog = new KeyFileDialog()) {
         dialog.SetDirectory(Environment.GetFolderPath(
                                 Environment.SpecialFolder.Personal));
         dialog.Exec();
         if (dialog.Result == (int)QDialog.DialogCode.Accepted)
         {
             var constraints = dialog.GetConstraints();
             foreach (var file in dialog.SelectedFiles)
             {
                 try {
                     KeyFormatter.GetPassphraseCallback passphraseCallback = () =>
                     {
                         var passphraseDialog = new PassphraseDialog();
                         passphraseDialog.Exec();
                         if (passphraseDialog.Result == (int)QDialog.DialogCode.Rejected)
                         {
                             return(null);
                         }
                         using (var passphrase =
                                    new PinnedArray <byte>(passphraseDialog.GetPassphrase()))
                         {
                             var securePassphrase = new SecureString();
                             foreach (var b in passphrase.Data)
                             {
                                 securePassphrase.AppendChar((char)b);
                             }
                             return(securePassphrase);
                         }
                     };
                     mAgent.AddKeyFromFile(file, passphraseCallback, constraints);
                 } catch (AgentFailureException) {
                     QMessageBox.Critical(this,
                                          Tr("Agent Failure"),
                                          Tr("Possible causes:") +
                                          "<ul>" + "</li>" +
                                          "<li>" + Tr("Agent is locked") + "</li>" +
                                          "<li>" + Tr("Agent does not support this key type") +
                                          "</ul>");
                 } catch (KeyFormatterException) {
                     QMessageBox.Critical(this,
                                          Tr("File format error"),
                                          Tr("This file not a recognized private key file") +
                                          "<br><br>" +
                                          file);
                 } catch (Exception ex) {
                     Debug.Fail(ex.ToString());
                 }
             }
         }
     }
     if (mAgent is Agent)
     {
         UpdateUIState();
     }
     else
     {
         ReloadData();
     }
 }
Beispiel #22
0
    private void LoadGoogleSettings()
    {
        Config google_config = Conf.Get("GoogleBackends");

        main.GMailSearchFolder.Text = google_config.GetOption("GMailSearchFolder",null);

        string username = google_config.GetOption("GMailUsername",null);

        if (!username.EndsWith("@gmail.com"))
        {
            username = null;
        }
        else
        {
            main.GoogleUsername.Text = username.Remove(username.Length - 10);
        }

        string google_apps_domain = google_config.GetOption("GoogleAppsAccountName",null);

        if (google_apps_domain != null)
        {
            google_apps_domain = google_apps_domain.Trim();
        }
        if (String.IsNullOrEmpty(google_apps_domain))
        {
            main.IsGoogleAppsAccount.Checked = false;
            main.GoogleAppsAccountName.SetDisabled(true);
        }
        else
        {
            main.IsGoogleAppsAccount.Checked = true;
            main.GoogleAppsAccountName.SetDisabled(false);
            main.GoogleAppsAccountName.Text = google_apps_domain;
        }

        string password_source = google_config.GetOption("GMailPasswordSource","conf-file");

        if (password_source == "gnome-keyring")
        {
            QMessageBox.Critical(this,"Google password storage option","Gnome keyring support not available from beagle-settings-qt");
            return;
        }

        if (password_source == "kdewallet")
        {
            if (String.IsNullOrEmpty(username))
            {
                return;
            }

            try {
                string password = KdeUtils.ReadPasswordKDEWallet("beagle",username);
                main.GooglePassword.Text = password;
                main.OptionStorePasswordKWallet.SetChecked(true);
            } catch (ArgumentException e) {
                QMessageBox.Warning(this,"KDEWallet",e.Message);
            }
            return;
        }

        if (password_source != "conf-file")
        {
            QMessageBox.Warning(this,"Google password storage option","Unknown password storage option.");
            return;
        }

        main.GooglePassword.Text = google_config.GetOption("GMailPassword",null);
        main.OptionStorePasswordConf.SetChecked(true);
    }