Changeset 6b83632 in Renga


Ignore:
Timestamp:
Dec 23, 2023, 2:57:52 PM (5 months ago)
Author:
PulkoMandy <pulkomandy@…>
Branches:
main
Children:
fadc861f
Parents:
3d47039
Message:

Fix crash on first anonymous connection

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • jabber/JabberSpeak.cpp

    r3d47039 r6b83632  
    114114const std::string JabberSpeak::CurrentRealName() const {
    115115        return _curr_realname;
    116 }
    117 
    118 const std::string JabberSpeak::CurrentLogin() const {
    119         return _curr_login;
    120116}
    121117
  • jabber/JabberSpeak.h

    r3d47039 r6b83632  
    7979        // SELECTORS
    8080        const std::string       CurrentRealName() const;
    81         const std::string       CurrentLogin() const;
    8281
    8382        // gloox::ConnectionListener
  • jabber/TalkManager.cpp

    r3d47039 r6b83632  
    614614
    615615                        // FIXME send a message to the view instead (locking and unlocking for every message is slow)
    616                         window->LockLooper();
     616                        bool isLocked = window->LockLooper();
     617                               
    617618
    618619                        // TODO: compare with JID instead?
     
    622623                                window->AddToTalk(group_username, runs, TalkView::MAIN_RECIPIENT, highlight, autoHyperlink);
    623624
    624                         window->UnlockLooper();
     625                        // May not be locked if the view is not added to a winow yet
     626                        if (isLocked)
     627                                window->UnlockLooper();
    625628                }
    626629        }
     
    646649
    647650        // FIXME just send a BMessage to the view and let it handle this
    648         window->LockLooper();
     651        bool isLocked = window->LockLooper();
    649652        window->SetStatus(subject);
    650653        std::list<TextSpan> runs;
    651654        runs.emplace_back(topic, TalkView::SystemMessagesStyle());
    652655        window->AddToTalk(nick, runs, TalkView::OTHER, false, true);
    653         window->UnlockLooper();
     656        if (isLocked)
     657                window->UnlockLooper();
    654658}
    655659
  • ui/MainWindow.cpp

    r3d47039 r6b83632  
    267267                        // we just logged in
    268268                        BString statusText;
    269                         statusText.SetToFormat(B_TRANSLATE("Connected as %s"), JabberSpeak::Instance()->CurrentLogin().c_str());
     269                        statusText.SetToFormat(B_TRANSLATE("Connected as %s"), JabberSpeak::Instance()->CurrentRealName().c_str());
    270270                        _status_view->SetText(statusText.String());
    271271
    272                         // save these settings
    273                         BlabberSettings::Instance()->SetData("last-realname", _login_realname->Text());
    274                         BlabberSettings::Instance()->SetData("last-login", _login_username->Text());
    275                         BlabberSettings::Instance()->RemoveData("last-password");
    276 
    277                         BKeyStore keystore;
    278                         keystore.AddKeyring("XMPP");
    279                         BPasswordKey key(_login_password->Text(), B_KEY_PURPOSE_GENERIC, _login_username->Text());
    280                         status_t status = keystore.AddKey("XMPP", key);
    281                         if (status != B_OK)
    282                                 fprintf(stderr, "failed to store password: %s\n", strerror(status));
    283 
    284                         BlabberSettings::Instance()->SetTag("auto-login", _login_auto_login->Value());
    285                         BlabberSettings::Instance()->WriteToFile();
     272                        if (_login_username->TextLength() > 0) {
     273                                // save these settings
     274                                BlabberSettings::Instance()->SetData("last-realname", _login_realname->Text());
     275                                BlabberSettings::Instance()->SetData("last-login", _login_username->Text());
     276                                BlabberSettings::Instance()->RemoveData("last-password");
     277
     278                                BKeyStore keystore;
     279                                keystore.AddKeyring("XMPP");
     280                                BPasswordKey key(_login_password->Text(), B_KEY_PURPOSE_GENERIC, _login_username->Text());
     281                                status_t status = keystore.AddKey("XMPP", key);
     282                                if (status != B_OK)
     283                                        fprintf(stderr, "failed to store password: %s\n", strerror(status));
     284
     285                                BlabberSettings::Instance()->SetTag("auto-login", _login_auto_login->Value());
     286                                BlabberSettings::Instance()->WriteToFile();
     287                        }
    286288
    287289                        break;
  • ui/TalkView.cpp

    r3d47039 r6b83632  
    178178        } else if (!uid || uid->UserType() == UserID::JABBER) {
    179179                // identify the user
    180                 sprintf(buffer, B_TRANSLATE("your identity is %s"), JabberSpeak::Instance()->CurrentLogin().c_str());
     180                sprintf(buffer, B_TRANSLATE("your identity is %s"), JabberSpeak::Instance()->CurrentRealName().c_str());
    181181                SetStatus(buffer);
    182182        } else {
     
    560560        std::string user = JabberSpeak::Instance()->CurrentRealName();
    561561
    562         // and if not :)
    563         if (user.empty())
    564                 user = JabberSpeak::Instance()->CurrentLogin();
    565 
    566562        return user;
    567563}
Note: See TracChangeset for help on using the changeset viewer.