Pārlūkot izejas kodu

Merge branch 'master' of github.com:deltachat/deltachat-ios

Bastian van de Wetering 7 gadi atpakaļ
vecāks
revīzija
d4f2b8d9e4

+ 1 - 1
deltachat-ios/AppDelegate.swift

@@ -89,7 +89,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
         print(versionString)
 
         //       - second param remains nil (user data for more than one mailbox)
-        mailboxPointer = mrmailbox_new(callback_ios, nil)
+        mailboxPointer = mrmailbox_new(callback_ios, nil, "iOS")
         guard mailboxPointer != nil else {
             fatalError("Error: mrmailbox_new returned nil")
         }

+ 11 - 6
deltachat-ios/ChatListController.swift

@@ -11,7 +11,7 @@ import UIKit
 class ChatListController: UIViewController {
 
     let chatTable = UITableView()
-    var chats: [String] = ["Eins", "Zwei", "Drei"]
+    var chats: [(String, String)] = [("Coffee Meeting", "Let's go or what? I..."), ("Daniela", "Did you hear about what Dr. J. was suggesting..."), ("Alice", "Did you receive..."), ("Bob", "Knock..."), ("Eva", "🍏")]
     
     let chatSource = ChatTableDataSource()
     let chatTableDelegate = ChatTableDelegate()
@@ -26,7 +26,6 @@ class ChatListController: UIViewController {
         chatTable.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
         chatTable.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
         chatTable.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
-        chatTable.register(UITableViewCell.self , forCellReuseIdentifier: "ChatCell")
         chatSource.chats = chats
         chatTable.dataSource = chatSource
         chatTableDelegate.chatPresenter = self
@@ -43,23 +42,29 @@ class ChatListController: UIViewController {
 extension ChatListController: ChatPresenter {
     func displayChat(index: Int) {
         let chatVC = UIViewController()
-        chatVC.title = chats[index]
+        chatVC.title = chats[index].0
         self.navigationController?.pushViewController(chatVC, animated: true)
     }
 }
 
 class ChatTableDataSource: NSObject, UITableViewDataSource  {
     
-    var chats: [String] = []
+    var chats: [(String, String)] = []
     
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
         return chats.count
     }
     
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-        let cell = tableView.dequeueReusableCell(withIdentifier: "ChatCell", for: indexPath)
-        let title = chats[indexPath.row]
+        let cell:UITableViewCell
+        if let c = tableView.dequeueReusableCell(withIdentifier: "ChatCell") {
+            cell = c
+        } else {
+            cell = UITableViewCell(style: .subtitle, reuseIdentifier: "ChatCell")
+        }
+        let title = chats[indexPath.row].0
         cell.textLabel?.text = title
+        cell.detailTextLabel?.text = chats[indexPath.row].1
         return cell
     }
 }

+ 1 - 1
deltachat-ios/libraries/deltachat-core/src/main.c

@@ -108,7 +108,7 @@ static uintptr_t receive_event(mrmailbox_t* mailbox, int event, uintptr_t data1,
 
 int main(int argc, char ** argv)
 {
-	mrmailbox_t* mailbox = mrmailbox_new(receive_event, NULL);
+	mrmailbox_t* mailbox = mrmailbox_new(receive_event, NULL, "CLI");
 
 	mrmailbox_cmdline_skip_auth(mailbox); /* disable the need to enter the command `auth <password>` for all mailboxes. */
 

+ 4 - 2
deltachat-ios/libraries/deltachat-core/src/mrmailbox.c

@@ -876,7 +876,7 @@ static void cb_receive_imf(mrimap_t* imap, const char* imf_raw_not_terminated, s
 }
 
 
-mrmailbox_t* mrmailbox_new(mrmailboxcb_t cb, void* userData)
+mrmailbox_t* mrmailbox_new(mrmailboxcb_t cb, void* userdata, const char* os_name)
 {
 	mrmailbox_get_thread_index(); /* make sure, the main thread has the index #1, only for a nicer look of the logs */
 
@@ -892,9 +892,10 @@ mrmailbox_t* mrmailbox_new(mrmailboxcb_t cb, void* userData)
 
 	ths->m_sql      = mrsqlite3_new(ths);
 	ths->m_cb       = cb? cb : cb_dummy;
-	ths->m_userData = userData;
+	ths->m_userdata = userdata;
 	ths->m_imap     = mrimap_new(cb_get_config_int, cb_set_config_int, cb_receive_imf, (void*)ths, ths);
 	ths->m_smtp     = mrsmtp_new(ths);
+	ths->m_os_name  = safe_strdup(os_name);
 
 	mrjob_init_thread(ths);
 
@@ -946,6 +947,7 @@ void mrmailbox_unref(mrmailbox_t* ths)
 		free(ths->m_log_ringbuf[i]);
 	}
 
+	free(ths->m_os_name);
 	free(ths);
 
 	if( s_localize_mb_obj==ths ) {

+ 9 - 3
deltachat-ios/libraries/deltachat-core/src/mrmailbox.h

@@ -121,7 +121,9 @@ typedef struct mrmailbox_t
 	int              m_job_do_exit;
 
 	mrmailboxcb_t    m_cb;
-	void*            m_userData;
+	void*            m_userdata;
+
+	char*            m_os_name;
 
 	uint32_t         m_cmdline_sel_chat_id;
 
@@ -141,8 +143,12 @@ typedef struct mrmailbox_t
 
 /* mrmailbox_new() creates a new mailbox object.  After creation it is usually
 opened, connected and mails are fetched; see the corresponding functions below.
-After usage, the mailbox object must be freed using mrmailbox_unref(). */
-mrmailbox_t*         mrmailbox_new                  (mrmailboxcb_t, void* userData);
+The os name is only for decorative use and is shown eg. in the X-Mailer header
+in the form "Delta Chat <version> for <osName>" */
+mrmailbox_t*         mrmailbox_new                  (mrmailboxcb_t, void* userData, const char* osName);
+
+/* After usage, the mailbox object must be freed using mrmailbox_unref().
+If app runs can only be terminated by a forced kill, this may be superfluous. */
 void                 mrmailbox_unref                (mrmailbox_t*);
 
 

+ 3 - 1
deltachat-ios/libraries/deltachat-core/src/mrmimefactory.c

@@ -477,7 +477,9 @@ int mrmimefactory_render(mrmimefactory_t* factory, int encrypt_to_self)
 			references_list /* references */,
 			NULL /* subject set later */);
 
-		mailimf_fields_add(imf_fields, mailimf_field_new_custom(strdup("X-Mailer"), mr_mprintf("Delta Chat %i.%i.%i", MR_VERSION_MAJOR, MR_VERSION_MINOR, MR_VERSION_REVISION))); /* only informational, for debugging, may be removed in the release. Also do not rely on this as it may be removed by MTAs. */
+		mailimf_fields_add(imf_fields, mailimf_field_new_custom(strdup("X-Mailer"),
+			mr_mprintf("Delta Chat %i.%i.%i for %s", MR_VERSION_MAJOR, MR_VERSION_MINOR, MR_VERSION_REVISION, factory->m_mailbox->m_os_name))); /* only informational, for debugging, may be removed in the release. Also do not rely on this as it may be removed by MTAs. */
+
 		mailimf_fields_add(imf_fields, mailimf_field_new_custom(strdup("X-MrMsg"), strdup("1.0"))); /* mark message as being sent by a messenger */
 		if( factory->m_predecessor ) {
 			mailimf_fields_add(imf_fields, mailimf_field_new_custom(strdup("X-MrPredecessor"), strdup(factory->m_predecessor)));

+ 2 - 0
deltachat-ios/libraries/deltachat-core/src/mrmsg.h

@@ -104,6 +104,8 @@ char*         mrmsg_get_filename           (mrmsg_t*); /* returns base file name
 mrpoortext_t* mrmsg_get_mediainfo          (mrmsg_t*); /* returns real author (as text1, this is not always the sender, NULL if unknown) and title (text2, NULL if unknown) */
 int           mrmsg_is_increation          (mrmsg_t*);
 void          mrmsg_save_param_to_disk     (mrmsg_t*); /* can be used to add some additional, persistent information to a messages record */
+
+/* only sets the text field, MR_MSG_TEXT must be set additionally */
 void          mrmsg_set_text               (mrmsg_t*, const char* text);
 
 

+ 1 - 2
get_libraries.sh

@@ -2,14 +2,13 @@
 
 base='../deltachat-core'
 dst=deltachat-ios/libraries
-# dst_deltachat_core="${dst}/deltachat-core"
 
 if [[ ! -d "${base}" ]]; then
     echo Error: deltachat-core repository expected in parent directory
     exit 1
 fi
 
-rm -rf "${dst}"
+rm -rf "${dst}"/deltachat-core
 mkdir -p "${dst}"
 cp -r "${base}" "$dst"
 rm -rf "$dst"/deltachat-core/.git*