Explorar el Código

use mrarray_t instead of C array

Alla Reinsch hace 7 años
padre
commit
e906c313c8

+ 1 - 2
deltachat-ios/ChatViewController.swift

@@ -25,8 +25,7 @@ class ChatViewController: MessagesViewController {
     
     func getMessageIds() {
         let c_messageIds = mrmailbox_get_chat_msgs(mailboxPointer, UInt32(self.chatId), 0, 0)
-        // FIXME!
-        // self.messageIds = Utils.copyAndFreeArray(inputArray: c_messageIds)
+        self.messageIds = Utils.copyAndFreeArray(inputArray: c_messageIds)
     }
     
     required init?(coder aDecoder: NSCoder) {

+ 1 - 2
deltachat-ios/ContactViewController.swift

@@ -27,8 +27,7 @@ class ContactViewController: UIViewController {
     
     override func viewWillAppear(_ animated: Bool) {
         let c_contacts = mrmailbox_get_known_contacts(mailboxPointer, nil)
-        // FIXME!
-        // self.contactIds = Utils.copyAndFreeArray(inputArray: c_contacts)
+        self.contactIds = Utils.copyAndFreeArray(inputArray: c_contacts)
         contactTableDataSource.contacts = self.contactIds
         contactTable.reloadData()
     }

+ 7 - 8
deltachat-ios/Utils.swift

@@ -12,23 +12,22 @@ import UIKit
 struct Utils {
     static func getContactIds() -> [Int] {
         let c_contacts = mrmailbox_get_known_contacts(mailboxPointer, nil)
-        // FIXME!
-        // return Utils.copyAndFreeArray(inputArray: c_contacts)
-        return []
+        return Utils.copyAndFreeArray(inputArray: c_contacts)
     }
 
     
-    static func copyAndFreeArray(inputArray:UnsafeMutablePointer<carray>?) -> [Int] {
+    static func copyAndFreeArray(inputArray:UnsafeMutablePointer<mrarray_t>?) -> [Int] {
         var acc:[Int] = []
-        let len = carray_count(inputArray)
+        let len = mrarray_get_cnt(inputArray)
         for i in 0 ..< len {
-            // FIXME!
-            // acc.append(Int(carray_get_uint32(inputArray, i)))
+            let e = mrarray_get_id(inputArray, i)
+            acc.append(Int(e))
         }
-        carray_free(inputArray)
+        mrarray_unref(inputArray)
         return acc
     }
     
+    
     static func isValid(_ email: String) -> Bool {
         let emailRegEx = "(?:[a-z0-9!#$%\\&'*+/=?\\^_`{|}~-]+(?:\\.[a-z0-9!#$%\\&'*+/=?\\^_`{|}"+"~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\"+"x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-"+"z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5"+"]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-"+"9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21"+"-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"
         

+ 1 - 0
deltachat-ios/deltachat-ios-Bridging-Header.h

@@ -9,4 +9,5 @@
 #include "mrmsg-private.h"
 #include "mrchat-private.h"
 #include "mrlot-private.h"
+#include "mrarray-private.h"
 #include "wrapper.h"