Changeset 9607

Show
Ignore:
Timestamp:
05/10/08 23:29:47 (7 months ago)
Author:
js
Message:

Store otr_userstates at the right place and create it the right way.
This fixes the crash when creating a new account, which made Gajim
unusable on systems where it never ran before.

Location:
trunk
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/config.h.in

    r7184 r9607  
    6464#undef HAVE_UNISTD_H 
    6565 
     66/* Define to the sub-directory in which libtool stores uninstalled libraries. 
     67   */ 
     68#undef LT_OBJDIR 
     69 
    6670/* Name of package */ 
    6771#undef PACKAGE 
  • trunk/src/chat_control.py

    r9603 r9607  
    12091209        def update_otr(self, print_status=False): 
    12101210                # retrieve the OTR context from the chat's contact data 
    1211                 ctx = gajim.otr_module.otrl_context_find(gajim.otr_userstates[self.account], 
     1211                ctx = gajim.otr_module.otrl_context_find(gajim.connections[self.account].otr_userstates, 
    12121212                        self.contact.get_full_jid().encode(), 
    12131213                        gajim.get_jid_from_account(self.account).encode(), gajim.OTR_PROTO, 1, 
     
    18521852                        self.handlers[id] = smp_otr_menuitem 
    18531853 
    1854                         ctx = gajim.otr_module.otrl_context_find(gajim.otr_userstates[self.account], 
     1854                        ctx = gajim.otr_module.otrl_context_find(gajim.connections[self.account].otr_userstates, 
    18551855                                self.contact.get_full_jid().encode(), 
    18561856                                gajim.get_jid_from_account(self.account).encode(), gajim.OTR_PROTO, 1, 
     
    23502350        def _on_end_otr_menuitem_activate(self, widget): 
    23512351                fjid = self.contact.get_full_jid() 
    2352                 gajim.otr_module.otrl_message_disconnect(gajim.otr_userstates[self.account], 
     2352                gajim.otr_module.otrl_message_disconnect(gajim.connections[self.account].otr_userstates, 
    23532353                                (gajim.otr_ui_ops, {'account':self.account,'urgent':True}), 
    23542354                                gajim.get_jid_from_account(self.account).encode(), gajim.OTR_PROTO, 
     
    23602360                gajim.otr_windows.ContactOtrWindow(self.contact, self.account, self) 
    23612361        def _on_smp_otr_menuitem_activate(self, widget): 
    2362                 ctx = gajim.otr_module.otrl_context_find(gajim.otr_userstates[self.account], 
     2362                ctx = gajim.otr_module.otrl_context_find(gajim.connections[self.account].otr_userstates, 
    23632363                        self.contact.get_full_jid().encode(), 
    23642364                        gajim.get_jid_from_account(self.account).encode(), gajim.OTR_PROTO, 1, 
  • trunk/src/common/connection_handlers.py

    r9605 r9607  
    16811681                        if gajim.otr_module and isinstance(msgtxt, unicode): 
    16821682                                otr_msg_tuple = gajim.otr_module.otrl_message_receiving( 
    1683                                         gajim.otr_userstates[self.name], 
     1683                                        gajim.connections[self.name].otr_userstates, 
    16841684                                        (gajim.otr_ui_ops, {'account':self.name}), 
    16851685                                        gajim.get_jid_from_account(self.name).encode(), 
     
    17001700                                                ctrl.update_ui() 
    17011701 
    1702                                 ctx = gajim.otr_module.otrl_context_find(gajim.otr_userstates[self.name], frm.encode(), 
     1702                                ctx = gajim.otr_module.otrl_context_find(gajim.connections[self.name].otr_userstates, frm.encode(), 
    17031703                                                gajim.get_jid_from_account(self.name).encode(), gajim.OTR_PROTO, 1, 
    17041704                                                (gajim.otr_add_appdata, self.name))[0] 
  • trunk/src/common/connection.py

    r9602 r9607  
    165165                self.vcard_supported = True 
    166166                self.private_storage_supported = True 
     167 
     168                if gajim.otr_module: 
     169                        self.otr_userstates = gajim.otr_module.otrl_userstate_create() 
     170 
     171                        try: 
     172                                gajim.otr_module.otrl_privkey_read(self.otr_userstates, 
     173                                        os.path.join(gajimpaths.root, 
     174                                        '%s.key' % self.name).encode()) 
     175                        except Exception, e: 
     176                                if hasattr(e, 'os_errno') and e.os_errno == 2: 
     177                                        pass 
     178 
     179                        try: 
     180                                gajim.otr_module.otrl_privkey_read_fingerprints( 
     181                                        self.otr_userstates, os.path.join( 
     182                                        gajimpaths.root, '%s.fpr' % self.name 
     183                                        ).encode(), (add_appdata, a)) 
     184                        except Exception, e: 
     185                                if hasattr(e, 'os_errno') and e.os_errno == 2: 
     186                                        pass 
    167187        # END __init__ 
    168188 
  • trunk/src/gajim.py

    r9602 r9607  
    320320                        gtk.main_iteration(block=False) 
    321321 
    322                 otr.otrl_privkey_generate(gajim.otr_userstates[opdata['account']], 
     322                otr.otrl_privkey_generate(gajim.connections[opdata['account']].otr_userstates, 
    323323                        os.path.join(gajimpaths.root, "%s.key"%opdata['account']).encode(), 
    324324                        accountname, gajim.OTR_PROTO) 
     
    372372 
    373373        def write_fingerprints(self, opdata=""): 
    374                 otr.otrl_privkey_write_fingerprints(gajim.otr_userstates[opdata['account']], 
     374                otr.otrl_privkey_write_fingerprints(gajim.connections[opdata['account']].otr_userstates, 
    375375                        os.path.join(gajimpaths.root, "%s.fpr"%opdata['account']).encode()) 
    376376 
     
    33273327                        gajim.transport_avatar[a] = {} 
    33283328 
    3329                         if gajim.otr_module: 
    3330                                 gajim.otr_userstates[a] = otr.otrl_userstate_create() 
    3331                                 try: 
    3332                                         otr.otrl_privkey_read(gajim.otr_userstates[a], 
    3333                                                 os.path.join(gajimpaths.root, "%s.key"%a).encode()) 
    3334                                 except Exception, e: 
    3335                                         if hasattr(e,"os_errno") and e.os_errno == 2: 
    3336                                                 print "didn't find otr keyfile "+ \ 
    3337                                                         (os.path.join(gajimpaths.root, "%s.key"%a).encode()) 
    3338                                                 pass 
    3339                                 try: 
    3340                                         otr.otrl_privkey_read_fingerprints(gajim.otr_userstates[a], 
    3341                                                 os.path.join(gajimpaths.root, "%s.fpr"%a).encode(), (add_appdata, a)) 
    3342                                 except Exception, e: 
    3343                                         if hasattr(e,"os_errno") and e.os_errno == 2: 
    3344                                                 print "didn't find otr fingerprint file "+ \ 
    3345                                                         (os.path.join(gajimpaths.root, "%s.fpr"%a).encode()) 
    3346                                                 pass 
    3347  
    33483329                if gajim.config.get('remote_control'): 
    33493330                        try: 
  • trunk/src/message_control.py

    r9602 r9607  
    161161         
    162162                                new_msg = gajim.otr_module.otrl_message_sending( 
    163                                         gajim.otr_userstates[self.account], 
     163                                        gajim.connections[self.account].otr_userstates, 
    164164                                        (gajim.otr_ui_ops, d), 
    165165                                        gajim.get_jid_from_account(self.account).encode(), gajim.OTR_PROTO, 
     
    167167 
    168168                                context = gajim.otr_module.otrl_context_find( 
    169                                                 gajim.otr_userstates[self.account], 
     169                                                gajim.connections[self.account].otr_userstates, 
    170170                                                self.contact.get_full_jid().encode(), 
    171171                                                gajim.get_jid_from_account(self.account).encode(), 
    172172                                                gajim.OTR_PROTO, 1)[0] 
    173  
    174                                 print repr(context.accountname), repr(context.username) 
    175173 
    176174                                # we send all because inject_message can filter on HTML stuff then 
  • trunk/src/otr_windows.py

    r9602 r9607  
    5050 
    5151                self.ctx = gajim.otr_module.otrl_context_find( 
    52                         gajim.otr_userstates[self.account], 
     52                        gajim.connections[self.account].otr_userstates, 
    5353                        self.fjid.encode(), gajim.get_jid_from_account(self.account).encode(), 
    5454                        gajim.OTR_PROTO, 1, (gajim.otr_add_appdata, self.account))[0] 
     
    8080        def _abort(self, text=None): 
    8181                self.smp_running = False 
    82                 gajim.otr_module.otrl_message_abort_smp(gajim.otr_userstates[self.account], 
     82                gajim.otr_module.otrl_message_abort_smp(gajim.connections[self.account].otr_userstates, 
    8383                                (gajim.otr_ui_ops, {'account':self.account}), self.ctx) 
    8484                if text: 
     
    153153                secret = self.gw("secret_entry").get_text() 
    154154                if self.response: 
    155                         gajim.otr_module.otrl_message_respond_smp(gajim.otr_userstates[self.account], 
     155                        gajim.otr_module.otrl_message_respond_smp(gajim.connections[self.account].otr_userstates, 
    156156                                        (gajim.otr_ui_ops, {'account':self.account}), self.ctx, secret) 
    157157                else: 
    158                         gajim.otr_module.otrl_message_initiate_smp(gajim.otr_userstates[self.account], 
     158                        gajim.otr_module.otrl_message_initiate_smp(gajim.connections[self.account].otr_userstates, 
    159159                                        (gajim.otr_ui_ops, {'account':self.account}), self.ctx, secret) 
    160160                        self.gw("progressbar").set_fraction(0.3) 
     
    175175 
    176176                self.ctx = gajim.otr_module.otrl_context_find( 
    177                         gajim.otr_userstates[self.account], 
     177                        gajim.connections[self.account].otr_userstates, 
    178178                        self.contact.get_full_jid().encode(), 
    179179                        gajim.get_jid_from_account(self.account).encode(), 
     
    194194                self.gw("our_fp_label").set_markup(our_fp_text% 
    195195                        gajim.otr_module.otrl_privkey_fingerprint( 
    196                                 gajim.otr_userstates[self.account], 
     196                                gajim.connections[self.account].otr_userstates, 
    197197                                gajim.get_jid_from_account(self.account).encode(), 
    198198                                gajim.OTR_PROTO)) 
  • trunk/src/roster_window.py

    r9602 r9607  
    17771777                                # offline/invisible 
    17781778                                if status == 'offline' or status == 'invisible': 
    1779                                         ctx = gajim.otr_userstates[account].context_root 
     1779                                        ctx = gajim.connections[account].otr_userstates.context_root 
    17801780                                        while ctx is not None: 
    17811781                                                if ctx.msgstate == gajim.otr_module.OTRL_MSGSTATE_ENCRYPTED: 
    17821782                                                        disconnected = True 
    1783                                                         gajim.otr_module.otrl_message_disconnect(gajim.otr_userstates[account], 
     1783                                                        gajim.otr_module.otrl_message_disconnect(gajim.connections[account].otr_userstates, 
    17841784                                                                        (gajim.otr_ui_ops, 
    17851785                                                                        {'account':account,'urgent':True}), ctx.accountname,