src/key_reset.c
branchsync_and_key_reset
changeset 2956 e82181973f21
parent 2948 3f66f366dc5f
child 3174 ca08de2591b7
     1.1 --- a/src/key_reset.c	Thu Sep 27 17:34:45 2018 +0200
     1.2 +++ b/src/key_reset.c	Fri Sep 28 10:07:05 2018 +0200
     1.3 @@ -123,7 +123,7 @@
     1.4      pEp_identity* temp_ident = identity_dup(sender_id);
     1.5      if (!temp_ident) {
     1.6          status = PEP_OUT_OF_MEMORY;
     1.7 -        goto pep_free;
     1.8 +        goto pEp_free;
     1.9      }        
    1.10              
    1.11      char* rest = NULL;
    1.12 @@ -132,7 +132,7 @@
    1.13          old_fpr = strdup(p + 5);
    1.14      else {
    1.15          status = PEP_MALFORMED_KEY_RESET_MSG;
    1.16 -        goto pep_free;
    1.17 +        goto pEp_free;
    1.18      }
    1.19      
    1.20      bool own_key = false;
    1.21 @@ -142,13 +142,13 @@
    1.22          // Nope, no one can make us our own default. If we want to do that,
    1.23          // that's keysync, NOT key reset.
    1.24          status = PEP_ILLEGAL_VALUE;
    1.25 -        goto pep_free;
    1.26 +        goto pEp_free;
    1.27      }
    1.28              
    1.29      p = strtok_r(NULL, "\r\n", &rest); 
    1.30      if (strncmp(p, "NEW: ", 5) != 0  || EMPTYSTR(p + 5)) {
    1.31          status = PEP_MALFORMED_KEY_RESET_MSG;
    1.32 -        goto pep_free;
    1.33 +        goto pEp_free;
    1.34      }
    1.35  
    1.36      new_fpr = strdup(p + 5);
    1.37 @@ -156,15 +156,15 @@
    1.38      // Reset the original key
    1.39      status = key_reset(session, old_fpr, temp_ident);
    1.40      if (status != PEP_STATUS_OK)
    1.41 -        goto pep_free;
    1.42 +        goto pEp_free;
    1.43          
    1.44      status = find_keys(session, new_fpr, &keylist);
    1.45      if (status != PEP_STATUS_OK)
    1.46 -        goto pep_free;
    1.47 +        goto pEp_free;
    1.48          
    1.49      if (!keylist) {
    1.50          status = PEP_KEY_NOT_FOUND;
    1.51 -        goto pep_free;
    1.52 +        goto pEp_free;
    1.53      }
    1.54  
    1.55      // alright, we've checked as best we can. Let's set that baby.
    1.56 @@ -175,7 +175,7 @@
    1.57      status = set_identity(session, sender_id);
    1.58      
    1.59      sender_id->fpr = NULL; // ownership for free
    1.60 -pep_free:    
    1.61 +pEp_free:    
    1.62      free_stringlist(keylist);    
    1.63      free(old_fpr);
    1.64      free(new_fpr);
    1.65 @@ -241,17 +241,12 @@
    1.66      assert(old_fpr);
    1.67      assert(new_fpr);
    1.68      assert(session);
    1.69 -    assert(session->messageToSend || session->sync_session->messageToSend);
    1.70 +    assert(session->messageToSend);
    1.71      
    1.72      if (!session || !old_fpr || !new_fpr)
    1.73          return PEP_ILLEGAL_VALUE;
    1.74  
    1.75 -    messageToSend_t send_cb = send_cb = session->messageToSend;
    1.76 -    void* sync_obj = session->sync_obj;
    1.77 -    if (!send_cb) {
    1.78 -        send_cb = session->sync_session->messageToSend;
    1.79 -        sync_obj = session->sync_session->sync_obj;
    1.80 -    }
    1.81 +    messageToSend_t send_cb = session->messageToSend;
    1.82      if (!send_cb)
    1.83          return PEP_SYNC_NO_MESSAGE_SEND_CALLBACK;
    1.84          
    1.85 @@ -261,7 +256,7 @@
    1.86      PEP_STATUS status = get_last_contacted(session, &recent_contacts);
    1.87      
    1.88      if (status != PEP_STATUS_OK)
    1.89 -        goto pep_free;
    1.90 +        goto pEp_free;
    1.91                      
    1.92      identity_list* curr_id_ptr = recent_contacts;
    1.93  
    1.94 @@ -285,7 +280,7 @@
    1.95          bool contacted = false;
    1.96          status = has_key_reset_been_sent(session, user_id, old_fpr, &contacted);
    1.97          if (status != PEP_STATUS_OK)
    1.98 -            goto pep_free;
    1.99 +            goto pEp_free;
   1.100      
   1.101          if (contacted)
   1.102              continue;
   1.103 @@ -306,24 +301,24 @@
   1.104              
   1.105          if (status != PEP_STATUS_OK) {
   1.106              free(reset_msg);
   1.107 -            goto pep_free;
   1.108 +            goto pEp_free;
   1.109          }
   1.110          
   1.111          // insert into queue
   1.112 -        status = send_cb(sync_obj, reset_msg);
   1.113 +        status = send_cb(reset_msg);
   1.114  
   1.115          if (status != PEP_STATUS_OK) {
   1.116              free(reset_msg);
   1.117 -            goto pep_free;            
   1.118 +            goto pEp_free;            
   1.119          }
   1.120              
   1.121          // Put into notified DB
   1.122          status = set_reset_contact_notified(session, old_fpr, user_id);
   1.123          if (status != PEP_STATUS_OK)
   1.124 -            goto pep_free;            
   1.125 +            goto pEp_free;            
   1.126      }
   1.127      
   1.128 -pep_free:
   1.129 +pEp_free:
   1.130      free_identity_list(recent_contacts);
   1.131      return status;
   1.132  }
   1.133 @@ -355,7 +350,7 @@
   1.134          // Get list of own identities
   1.135          status = get_default_own_userid(session, &own_id);
   1.136          if (status != PEP_STATUS_OK)
   1.137 -            goto pep_free;
   1.138 +            goto pEp_free;
   1.139              
   1.140          if (EMPTYSTR(fpr_copy)) {
   1.141              status = get_all_keys_for_user(session, own_id, &keys);
   1.142 @@ -367,7 +362,7 @@
   1.143                          break;
   1.144                  }
   1.145              }
   1.146 -            goto pep_free;
   1.147 +            goto pEp_free;
   1.148          } // otherwise, we have a specific fpr to process
   1.149  
   1.150          // fpr_copy exists, so... let's go.
   1.151 @@ -385,7 +380,7 @@
   1.152                      break;                    
   1.153              }
   1.154          }
   1.155 -        goto pep_free;
   1.156 +        goto pEp_free;
   1.157      }
   1.158      else { // an identity was specified.       
   1.159          if (is_me(session, ident)) {            
   1.160 @@ -473,7 +468,7 @@
   1.161          }
   1.162      }
   1.163      
   1.164 -pep_free:
   1.165 +pEp_free:
   1.166      free(fpr_copy);
   1.167      free(own_id);
   1.168      free_identity_list(key_idents);