Exemplo n.º 1
0
def delete_contact( pubkey_str, email_addr ):
   global STORAGE_DIR, CACHED_CONTACT_LIST
   
   contact_path = make_contact_path( pubkey_str, email_addr )
   
   rc = storage.delete_file( contact_path )
   if not rc:
      log.exception( Exception("Failed to detete contact") )
      return False
   
   else:
      storage.purge_cache( CACHED_CONTACT_LIST )
      
   return True
Exemplo n.º 2
0
def delete_message( pubkey_str, folder, msg_timestamp, msg_id ):
   rc = storage.delete_file( stored_message_path( pubkey_str, folder, msg_timestamp, msg_id ) )
   storage.purge_cache( folder_cache_name( folder ) )
   return rc
Exemplo n.º 3
0
   
   contact_path = make_contact_path( pubkey_str, contact.addr )
   
   try:
      contact_json = storage.tuple_to_json( contact )
   except Exception, e:
      log.error("Failed to serialize contact")
      log.exception(e)
      return False
   
   rc = storage.write_encrypted_file( pubkey_str, contact_path, contact_json )
   if not rc:
      return False
   
   # purge contacts cache
   storage.purge_cache( CACHED_CONTACT_LIST )
   return True
   

# -------------------------------------
def contact_exists( pubkey_str, email_addr ):
   contact_path = make_contact_path( pubkey_str, email_addr )
   return storage.path_exists( contact_path )
   
# -------------------------------------
def add_contact( pubkey_str, email_addr, contact_pubkey_str, contact_fields ):
   try:
      parsed_addr = parse_addr( email_addr )
   except:
      raise Exception("Invalid email address %s" % email_addr )
   
Exemplo n.º 4
0
      rc = storage.write_encrypted_file( receiver_pubkey_str, attachment_path, attachment_data )
      if not rc:
         failed = True
         break
      
      stored.append( attachment_path )
   """
   if failed:
      # roll back
      for path in stored:
         storage.delete_file( path )
      
      return False
   
   else:
      storage.purge_cache( folder_cache_name( folder ) )
      return True


#-------------------------
def read_stored_message( privkey_str, folder, msg_timestamp, msg_id, volume=None, receiver_pubkey_pem=None ):
   if receiver_pubkey_pem is None:
      pkey = CryptoKey.importKey( privkey_str )
      receiver_pubkey_pem = pkey.publickey().exportKey()

   mpath = stored_message_path( receiver_pubkey_pem, folder, msg_timestamp, msg_id )
   
   if not storage.path_exists( mpath, volume=volume ):
      log.error("No message at %s" % mpath )
      return None