ソースを参照

cleanup / move core wrapper stuff to Wrapper file

Jonas Reinsch 7 年 前
コミット
5f6ab5b8c5

+ 0 - 3
deltachat-ios/AppCoordinator.swift

@@ -12,7 +12,6 @@ protocol Coordinator {
     func setupViewControllers(window: UIWindow)
 }
 
-
 class AppCoordinator: Coordinator {
     
     func setupViewControllers(window: UIWindow) {
@@ -51,6 +50,4 @@ class AppCoordinator: Coordinator {
         window.makeKeyAndVisible()
         window.backgroundColor = UIColor.white
     }
-    
 }
-

+ 0 - 150
deltachat-ios/ChatListController.swift

@@ -8,154 +8,6 @@
 
 import UIKit
 
-class MRMessage {
-    
-    private var messagePointer: UnsafeMutablePointer<mrmsg_t>
-    
-    var id: Int {
-        return Int(messagePointer.pointee.m_id)
-    }
-    
-    var fromContactId: Int {
-        return Int(messagePointer.pointee.m_from_id)
-    }
-    
-    var toContactId: Int {
-        return Int(messagePointer.pointee.m_to_id)
-    }
-    
-    var chatId: Int {
-        return Int(messagePointer.pointee.m_chat_id)
-    }
-    
-    var text: String? {
-        return String(cString: messagePointer.pointee.m_text)
-    }
-    
-    // MR_MSG_*
-    var type: Int {
-        return Int(messagePointer.pointee.m_type)
-    }
-    
-    // MR_STATE_*
-    var state: Int {
-        return Int(messagePointer.pointee.m_state)
-    }
-    
-    var timestamp: Int64 {
-        return Int64(messagePointer.pointee.m_timestamp)
-    }
-    
-    init(id: Int) {
-        messagePointer = mrmailbox_get_msg(mailboxPointer, UInt32(id))
-    }
-    
-    deinit {
-        mrmsg_unref(messagePointer)
-    }
-}
-
-class MRChat {
-    
-    private var chatPointer: UnsafeMutablePointer<mrchat_t>
-    
-    var id: Int {
-        return Int(chatPointer.pointee.m_id)
-    }
-    
-    var name: String {
-        if chatPointer.pointee.m_name == nil {
-            return "Error - no name"
-        }
-        return String(cString: chatPointer.pointee.m_name)
-    }
-    
-    var type: Int {
-        return Int(chatPointer.pointee.m_type)
-    }
-    
-    init(id: Int) {
-        chatPointer = mrmailbox_get_chat(mailboxPointer, UInt32(id))
-    }
-    
-    deinit {
-        mrchat_unref(chatPointer)
-    }
-}
-
-class MRPoorText {
-    
-    private var poorTextPointer: UnsafeMutablePointer<mrpoortext_t>
-    
-    var text1: String? {
-        if poorTextPointer.pointee.m_text1 == nil {
-            return nil
-        }
-        return String(cString: poorTextPointer.pointee.m_text1)
-    }
-    
-    var text2: String? {
-        if poorTextPointer.pointee.m_text2 == nil {
-            return nil
-        }
-        return String(cString: poorTextPointer.pointee.m_text2)
-    }
-    
-    var text1Meaning: Int {
-        return Int(poorTextPointer.pointee.m_text1_meaning)
-    }
-    
-    var timeStamp: Int {
-        return Int(poorTextPointer.pointee.m_timestamp)
-    }
-    
-    var state: Int {
-        return Int(poorTextPointer.pointee.m_state)
-    }
-    
-    // takes ownership of specified pointer
-    init(poorTextPointer: UnsafeMutablePointer<mrpoortext_t>) {
-        self.poorTextPointer = poorTextPointer
-    }
-    
-    deinit {
-        mrpoortext_unref(poorTextPointer)
-    }
-}
-
-class MRChatList {
-    
-    private var chatListPointer: UnsafeMutablePointer<mrchatlist_t>
-    
-    var length: Int {
-        return mrchatlist_get_cnt(chatListPointer)
-        //return Int(chatListPointer.pointee.m_cnt)
-    }
-    
-    // takes ownership of specified pointer
-    init(chatListPointer: UnsafeMutablePointer<mrchatlist_t>) {
-        self.chatListPointer = chatListPointer
-    }
-
-    func getChatId(index: Int) -> Int {
-        return Int(mrchatlist_get_chat_id_by_index(self.chatListPointer, index))
-    }
-    
-    func getMessageId(index: Int) -> Int {
-        return Int(mrchatlist_get_msg_id_by_index(self.chatListPointer, index))
-    }
-    
-    func summary(index: Int) -> MRPoorText {
-        guard let poorTextPointer = mrchatlist_get_summary_by_index(self.chatListPointer, index, nil) else {
-            fatalError("poor text pointer was nil")
-        }
-        return MRPoorText(poorTextPointer: poorTextPointer)
-    }
-    
-    deinit {
-        mrchatlist_unref(chatListPointer)
-    }
-}
 
 
 class ChatListController: UIViewController {
@@ -302,6 +154,4 @@ class ChatTableDelegate: NSObject, UITableViewDelegate {
         let row = indexPath.row
         chatPresenter?.displayChat(index: row)
     }
-    
 }
-

+ 0 - 4
deltachat-ios/ChatViewController.swift

@@ -21,8 +21,6 @@ class ChatViewController: MessagesViewController {
         self.chatId = chatId
         super.init(nibName: nil, bundle: nil)
         self.getMessageIds()
-
-
     }
     
     func getMessageIds() {
@@ -436,6 +434,4 @@ extension ChatViewController: MessageInputBarDelegate {
 //        messagesCollectionView.reloadData()
 //        messagesCollectionView.scrollToBottom()
     }
-
-
 }

+ 1 - 4
deltachat-ios/Constants.swift

@@ -9,10 +9,7 @@
 import UIKit
 
 struct Constants {
-    
-    struct Color {
+     struct Color {
         static let bubble = UIColor(netHex: 0xefffde)
-        
     }
-    
 }

+ 0 - 30
deltachat-ios/ContactViewController.swift

@@ -8,36 +8,6 @@
 
 import UIKit
 
-class MRContact {
-    private var contactPointer: UnsafeMutablePointer<mrcontact_t>
-
-    var name: String {
-        if contactPointer.pointee.m_name == nil {
-            return email
-        }
-        return String(cString: contactPointer.pointee.m_name)
-    }
-    
-    var email: String {
-        if contactPointer.pointee.m_addr == nil {
-            return "error: no email in contact"
-        }
-        return String(cString: contactPointer.pointee.m_addr)
-    }
-    
-    var id: Int {
-        return Int(contactPointer.pointee.m_id)
-    }
-    
-    init(id: Int) {
-        contactPointer = mrmailbox_get_contact(mailboxPointer, UInt32(id))
-    }
-    
-    deinit {
-        mrcontact_unref(contactPointer)
-    }
-}
-
 class ContactViewController: UIViewController {
     var coordinator: Coordinator
     var contactIds: [Int] = []

+ 0 - 1
deltachat-ios/SampleData.swift

@@ -142,7 +142,6 @@ final class SampleData {
     }
     
     func randomMessage() -> Message {
-        
         let randomNumberSender = Int(arc4random_uniform(UInt32(senders.count)))
         let randomNumberText = Int(arc4random_uniform(UInt32(messageTextValues.count)))
         let randomNumberImage = Int(arc4random_uniform(UInt32(messageImages.count)))

+ 180 - 0
deltachat-ios/Wrapper.swift

@@ -7,3 +7,183 @@
 //
 
 import Foundation
+
+
+class MRContact {
+    private var contactPointer: UnsafeMutablePointer<mrcontact_t>
+    
+    var name: String {
+        if contactPointer.pointee.m_name == nil {
+            return email
+        }
+        return String(cString: contactPointer.pointee.m_name)
+    }
+    
+    var email: String {
+        if contactPointer.pointee.m_addr == nil {
+            return "error: no email in contact"
+        }
+        return String(cString: contactPointer.pointee.m_addr)
+    }
+    
+    var id: Int {
+        return Int(contactPointer.pointee.m_id)
+    }
+    
+    init(id: Int) {
+        contactPointer = mrmailbox_get_contact(mailboxPointer, UInt32(id))
+    }
+    
+    deinit {
+        mrcontact_unref(contactPointer)
+    }
+}
+
+
+class MRMessage {
+    private var messagePointer: UnsafeMutablePointer<mrmsg_t>
+    
+    var id: Int {
+        return Int(messagePointer.pointee.m_id)
+    }
+    
+    var fromContactId: Int {
+        return Int(messagePointer.pointee.m_from_id)
+    }
+    
+    var toContactId: Int {
+        return Int(messagePointer.pointee.m_to_id)
+    }
+    
+    var chatId: Int {
+        return Int(messagePointer.pointee.m_chat_id)
+    }
+    
+    var text: String? {
+        return String(cString: messagePointer.pointee.m_text)
+    }
+    
+    // MR_MSG_*
+    var type: Int {
+        return Int(messagePointer.pointee.m_type)
+    }
+    
+    // MR_STATE_*
+    var state: Int {
+        return Int(messagePointer.pointee.m_state)
+    }
+    
+    var timestamp: Int64 {
+        return Int64(messagePointer.pointee.m_timestamp)
+    }
+    
+    init(id: Int) {
+        messagePointer = mrmailbox_get_msg(mailboxPointer, UInt32(id))
+    }
+    
+    deinit {
+        mrmsg_unref(messagePointer)
+    }
+}
+
+class MRChat {
+    
+    private var chatPointer: UnsafeMutablePointer<mrchat_t>
+    
+    var id: Int {
+        return Int(chatPointer.pointee.m_id)
+    }
+    
+    var name: String {
+        if chatPointer.pointee.m_name == nil {
+            return "Error - no name"
+        }
+        return String(cString: chatPointer.pointee.m_name)
+    }
+    
+    var type: Int {
+        return Int(chatPointer.pointee.m_type)
+    }
+    
+    init(id: Int) {
+        chatPointer = mrmailbox_get_chat(mailboxPointer, UInt32(id))
+    }
+    
+    deinit {
+        mrchat_unref(chatPointer)
+    }
+}
+
+class MRPoorText {
+    
+    private var poorTextPointer: UnsafeMutablePointer<mrpoortext_t>
+    
+    var text1: String? {
+        if poorTextPointer.pointee.m_text1 == nil {
+            return nil
+        }
+        return String(cString: poorTextPointer.pointee.m_text1)
+    }
+    
+    var text2: String? {
+        if poorTextPointer.pointee.m_text2 == nil {
+            return nil
+        }
+        return String(cString: poorTextPointer.pointee.m_text2)
+    }
+    
+    var text1Meaning: Int {
+        return Int(poorTextPointer.pointee.m_text1_meaning)
+    }
+    
+    var timeStamp: Int {
+        return Int(poorTextPointer.pointee.m_timestamp)
+    }
+    
+    var state: Int {
+        return Int(poorTextPointer.pointee.m_state)
+    }
+    
+    // takes ownership of specified pointer
+    init(poorTextPointer: UnsafeMutablePointer<mrpoortext_t>) {
+        self.poorTextPointer = poorTextPointer
+    }
+    
+    deinit {
+        mrpoortext_unref(poorTextPointer)
+    }
+}
+
+class MRChatList {
+    
+    private var chatListPointer: UnsafeMutablePointer<mrchatlist_t>
+    
+    var length: Int {
+        return mrchatlist_get_cnt(chatListPointer)
+        //return Int(chatListPointer.pointee.m_cnt)
+    }
+    
+    // takes ownership of specified pointer
+    init(chatListPointer: UnsafeMutablePointer<mrchatlist_t>) {
+        self.chatListPointer = chatListPointer
+    }
+    
+    func getChatId(index: Int) -> Int {
+        return Int(mrchatlist_get_chat_id_by_index(self.chatListPointer, index))
+    }
+    
+    func getMessageId(index: Int) -> Int {
+        return Int(mrchatlist_get_msg_id_by_index(self.chatListPointer, index))
+    }
+    
+    func summary(index: Int) -> MRPoorText {
+        guard let poorTextPointer = mrchatlist_get_summary_by_index(self.chatListPointer, index, nil) else {
+            fatalError("poor text pointer was nil")
+        }
+        return MRPoorText(poorTextPointer: poorTextPointer)
+    }
+    
+    deinit {
+        mrchatlist_unref(chatListPointer)
+    }
+}