pEpForiOS/UI/EmailDisplay/EmailListViewController.swift
author Dirk Zimmermann <dirk@pep-project.org>
Mon, 24 Apr 2017 15:36:29 +0200
changeset 2067 a4fb0b2e9cd9
parent 2041 eaac91f98aab
child 2132 4289912d9366
permissions -rw-r--r--
IOS-462 cosmetics
dirk@30
     1
//
dirk@30
     2
//  EmailListViewController.swift
dirk@30
     3
//  pEpForiOS
dirk@30
     4
//
dirk@30
     5
//  Created by Dirk Zimmermann on 16/04/16.
dirk@30
     6
//  Copyright © 2016 p≡p Security S.A. All rights reserved.
dirk@30
     7
//
dirk@30
     8
dirk@30
     9
import Foundation
dirk@30
    10
import UIKit
dirk@31
    11
import CoreData
dirk@810
    12
import MessageModel
dirk@810
    13
igor@1260
    14
struct EmailListConfig {
igor@1338
    15
    var appConfig: AppConfig?
dirk@1333
    16
igor@1260
    17
    /** The folder to display, if it exists */
igor@1260
    18
    var folder: Folder?
dirk@1906
    19
dirk@1906
    20
    let imageProvider = IdentityImageProvider()
igor@1260
    21
}
dirk@30
    22
xavier@1865
    23
class EmailListViewController: UITableViewController, FilterUpdateProtocol {
dirk@583
    24
    struct UIState {
dirk@583
    25
        var isSynching: Bool = false
dirk@583
    26
    }
dirk@30
    27
dirk@1344
    28
    var config: EmailListConfig?
dirk@275
    29
    var state = UIState()
igor@1301
    30
    let searchController = UISearchController(searchResultsController: nil)
dirk@1737
    31
    let cellsInUse = NSCache<NSString, EmailListViewCell>()
dirk@719
    32
dirk@1724
    33
    /**
dirk@1724
    34
     After trustwords have been invoked, this will be the partner identity that
dirk@1724
    35
     was either confirmed or mistrusted.
dirk@1724
    36
     */
dirk@1724
    37
    var partnerIdentity: Identity?
dirk@1724
    38
dirk@2067
    39
    @IBOutlet weak var enableFilterButton: UIBarButtonItem!
dirk@2067
    40
    @IBOutlet weak var textFilterButton: UIBarButtonItem!
dirk@2067
    41
dirk@2067
    42
    private var filterEnabled = false
dirk@2067
    43
dirk@275
    44
    override func viewDidLoad() {
ylandert@935
    45
        super.viewDidLoad()
xavier@1623
    46
igor@1408
    47
        title = "EmailList.title".localized
igor@1284
    48
        UIHelper.emailListTableHeight(self.tableView)
igor@1301
    49
        addSearchBar()
dirk@275
    50
    }
dirk@31
    51
dirk@784
    52
    override func viewWillAppear(_ animated: Bool) {
igor@1301
    53
        super.viewWillAppear(animated)
xavier@1623
    54
dirk@1344
    55
        if MiscUtil.isUnitTest() {
dirk@1344
    56
            return
dirk@1344
    57
        }
dirk@1344
    58
xavier@1832
    59
        self.textFilterButton.isEnabled = filterEnabled
xavier@1832
    60
dirk@1826
    61
        setDefaultColors()
dirk@1344
    62
        initialConfig()
dirk@854
    63
        updateModel()
dirk@1348
    64
dirk@1348
    65
        MessageModelConfig.messageFolderDelegate = self
dirk@1348
    66
    }
dirk@1348
    67
xavier@1948
    68
dirk@1348
    69
    override func viewWillDisappear(_ animated: Bool) {
dirk@1348
    70
        super.viewWillDisappear(animated)
dirk@1348
    71
        MessageModelConfig.messageFolderDelegate = nil
igor@1301
    72
    }
xavier@1623
    73
igor@1338
    74
    func initialConfig() {
dirk@1344
    75
        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
igor@1338
    76
            return
igor@1338
    77
        }
dirk@1344
    78
dirk@1344
    79
        if config == nil {
igor@1395
    80
            config = EmailListConfig(appConfig: appDelegate.appConfig, folder: Folder.unifiedInbox())
xavier@2041
    81
        } else if config?.folder != nil {
xavier@2041
    82
dirk@1344
    83
        }
dirk@1348
    84
        if Account.all().isEmpty {
igor@1338
    85
            performSegue(withIdentifier:.segueAddNewAccount, sender: self)
igor@1338
    86
        }
igor@1338
    87
    }
xavier@1623
    88
igor@1301
    89
    func addSearchBar() {
igor@1301
    90
        searchController.searchResultsUpdater = self
igor@1301
    91
        searchController.dimsBackgroundDuringPresentation = false
igor@1301
    92
        searchController.delegate = self
igor@1301
    93
        definesPresentationContext = true
igor@1301
    94
        tableView.tableHeaderView = searchController.searchBar
igor@1301
    95
        tableView.setContentOffset(CGPoint(x: 0.0, y: 40.0), animated: false)
igor@1301
    96
    }
dirk@705
    97
dirk@854
    98
    func updateModel() {
igor@1318
    99
        tableView.reloadData()
dirk@31
   100
    }
dirk@31
   101
xavier@1832
   102
xavier@1832
   103
    @IBAction func showUnreadButtonTapped(_ sender: UIBarButtonItem) {
xavier@1832
   104
        if filterEnabled {
xavier@1832
   105
            filterEnabled = false
xavier@1832
   106
            textFilterButton.title = ""
xavier@1832
   107
            enableFilterButton.image = UIImage(named: "unread-icon")
xavier@1865
   108
            updateFilter(filter: Filter.unified())
xavier@1832
   109
        } else {
xavier@1832
   110
            filterEnabled = true
xavier@1832
   111
            textFilterButton.title = "Filter by: unread"
xavier@1832
   112
            enableFilterButton.image = UIImage(named: "unread-icon-active")
xavier@1832
   113
            if config != nil {
xavier@1865
   114
                updateFilter(filter: Filter.unread())
xavier@1832
   115
            }
xavier@1832
   116
        }
xavier@1832
   117
        self.textFilterButton.isEnabled = filterEnabled
xavier@1832
   118
xavier@1832
   119
    }
xavier@1832
   120
xavier@1865
   121
    func updateFilter(filter: Filter) {
xavier@1865
   122
        config?.folder?.updateFilter(filter: filter)
xavier@1865
   123
        self.tableView.reloadData()
xavier@1865
   124
    }
xavier@1865
   125
dirk@58
   126
    // MARK: - UI State
dirk@58
   127
dirk@58
   128
    func updateUI() {
dirk@784
   129
        UIApplication.shared.isNetworkActivityIndicatorVisible = state.isSynching
dirk@748
   130
        if !state.isSynching {
igor@1260
   131
            refreshControl?.endRefreshing()
dirk@58
   132
        }
dirk@58
   133
    }
dirk@58
   134
dirk@31
   135
    // MARK: - UITableViewDataSource
dirk@31
   136
dirk@784
   137
    override func numberOfSections(in tableView: UITableView) -> Int {
dirk@1344
   138
        if let _ = config?.folder {
dirk@854
   139
            return 1
dirk@209
   140
        }
dirk@854
   141
        return 0
dirk@31
   142
    }
dirk@31
   143
dirk@784
   144
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
dirk@1344
   145
        if let fol = config?.folder  {
dirk@854
   146
            return fol.messageCount()
dirk@31
   147
        }
dirk@31
   148
        return 0
dirk@31
   149
    }
dirk@31
   150
dirk@784
   151
    override func tableView(_ tableView: UITableView,
dirk@784
   152
                            cellForRowAt indexPath: IndexPath) -> UITableViewCell {
dirk@784
   153
        let cell = tableView.dequeueReusableCell(
dirk@784
   154
            withIdentifier: "EmailListViewCell", for: indexPath) as! EmailListViewCell
dirk@1737
   155
        if let message = cell.configureCell(config: config, indexPath: indexPath) {
dirk@1737
   156
            associate(message: message, toCell: cell)
dirk@1542
   157
        }
dirk@31
   158
        return cell
dirk@31
   159
    }
dirk@31
   160
dirk@719
   161
    // MARK: - UITableViewDelegate
dirk@719
   162
dirk@784
   163
    override func tableView(_ tableView: UITableView, editActionsForRowAt
dirk@784
   164
        indexPath: IndexPath)-> [UITableViewRowAction]? {
xavier@1623
   165
dirk@784
   166
        let cell = tableView.cellForRow(at: indexPath) as! EmailListViewCell
igor@1260
   167
        if let email = cell.messageAt(indexPath: indexPath, config: config) {
igor@1576
   168
            let flagAction = createFlagAction(message: email, cell: cell)
dirk@1507
   169
            let deleteAction = createDeleteAction(message: email, cell: cell)
igor@1242
   170
            let moreAction = createMoreAction(message: email, cell: cell)
igor@1576
   171
            return [deleteAction, flagAction, moreAction]
dirk@855
   172
        }
dirk@855
   173
        return nil
dirk@744
   174
    }
dirk@744
   175
dirk@719
   176
    // MARK: - Misc
dirk@719
   177
dirk@1507
   178
    func createRowAction(cell: EmailListViewCell,
xavier@1623
   179
                         image: UIImage?, action: @escaping (UITableViewRowAction, IndexPath) -> Void,
xavier@1623
   180
                         title: String) -> UITableViewRowAction {
dirk@1510
   181
        let rowAction = UITableViewRowAction(
dirk@1510
   182
            style: .normal, title: title, handler: action)
dirk@1507
   183
dirk@1507
   184
        if let theImage = image {
dirk@1507
   185
            let iconColor = UIColor(patternImage: theImage)
dirk@1507
   186
            rowAction.backgroundColor = iconColor
dirk@744
   187
        }
dirk@744
   188
dirk@1507
   189
        return rowAction
dirk@744
   190
    }
dirk@744
   191
dirk@1507
   192
    func createFlagAction(message: Message, cell: EmailListViewCell) -> UITableViewRowAction {
dirk@1507
   193
        func action(action: UITableViewRowAction, indexPath: IndexPath) -> Void {
dirk@1522
   194
            if message.imapFlags == nil {
dirk@1522
   195
                Log.warn(component: #function, content: "message.imapFlags == nil")
dirk@1522
   196
            }
dirk@1605
   197
            if cell.isFlagged(message: message) {
dirk@1507
   198
                message.imapFlags?.flagged = false
dirk@1507
   199
            } else {
dirk@1507
   200
                message.imapFlags?.flagged = true
dirk@1507
   201
            }
dirk@1507
   202
            message.save()
dirk@1507
   203
            self.tableView.reloadRows(at: [indexPath], with: .none)
dirk@1507
   204
        }
dirk@1510
   205
igor@1523
   206
        var title = "\n\nFlag".localized
dirk@1605
   207
        if message.imapFlags?.flagged ?? true {
igor@1530
   208
            title = "\n\nUnFlag".localized
dirk@744
   209
        }
dirk@744
   210
dirk@1510
   211
        return createRowAction(
dirk@1510
   212
            cell: cell, image: UIImage(named: "swipe-flag"), action: action, title: title)
dirk@744
   213
    }
dirk@744
   214
dirk@1507
   215
    func createDeleteAction(message: Message, cell: EmailListViewCell) -> UITableViewRowAction {
dirk@1507
   216
        func action(action: UITableViewRowAction, indexPath: IndexPath) -> Void {
dirk@1507
   217
            guard let message = cell.messageAt(indexPath: indexPath, config: self.config) else {
dirk@1507
   218
                return
dirk@1507
   219
            }
xavier@1623
   220
dirk@1650
   221
            message.delete() // mark for deletion/trash
dirk@1507
   222
            message.save()
igor@1576
   223
            self.tableView.reloadData()
dirk@1507
   224
        }
dirk@744
   225
dirk@1510
   226
        return createRowAction(
dirk@1510
   227
            cell: cell, image: UIImage(named: "swipe-trash"), action: action,
igor@1523
   228
            title: "\n\nDelete".localized)
dirk@1507
   229
    }
dirk@1507
   230
dirk@1507
   231
    func createMarkAsReadAction(message: Message, cell: EmailListViewCell) -> UITableViewRowAction {
dirk@1507
   232
        func action(action: UITableViewRowAction, indexPath: IndexPath) -> Void {
dirk@1605
   233
            if cell.haveSeen(message: message) {
dirk@1507
   234
                message.imapFlags?.seen = false
dirk@1507
   235
            } else {
dirk@1507
   236
                message.imapFlags?.seen = true
dirk@1507
   237
            }
dirk@1507
   238
            self.tableView.reloadRows(at: [indexPath], with: .none)
dirk@744
   239
        }
dirk@1510
   240
dirk@1510
   241
        var title = NSLocalizedString(
dirk@1510
   242
            "Unread", comment: "Unread button title in swipe action on EmailListViewController")
dirk@1605
   243
        if !cell.haveSeen(message: message) {
dirk@1510
   244
            title = NSLocalizedString(
dirk@1510
   245
                "Read", comment: "Read button title in swipe action on EmailListViewController")
dirk@1507
   246
        }
dirk@1507
   247
dirk@1507
   248
        let isReadAction = createRowAction(cell: cell, image: nil, action: action,
dirk@1510
   249
                                           title: title)
dirk@784
   250
        isReadAction.backgroundColor = UIColor.blue
dirk@744
   251
dirk@744
   252
        return isReadAction
dirk@744
   253
    }
xavier@1623
   254
igor@1242
   255
    func createMoreAction(message: Message, cell: EmailListViewCell) -> UITableViewRowAction {
dirk@1510
   256
        func action(action: UITableViewRowAction, indexPath: IndexPath) -> Void {
igor@1242
   257
            self.showMoreActionSheet(cell: cell)
igor@1242
   258
        }
dirk@1510
   259
dirk@1510
   260
        return createRowAction(
dirk@1510
   261
            cell: cell, image: UIImage(named: "swipe-more"), action: action,
igor@1523
   262
            title: "\n\nMore".localized)
igor@1242
   263
    }
xavier@1623
   264
igor@1242
   265
    // MARK: - Action Sheet
xavier@1623
   266
igor@1242
   267
    func showMoreActionSheet(cell: EmailListViewCell) {
igor@1242
   268
        let alertControler = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
igor@1438
   269
        alertControler.view.tintColor = .pEpGreen
igor@1242
   270
        let cancelAction = createCancelAction()
igor@1242
   271
        let replyAction = createReplyAction(cell: cell)
xavier@1623
   272
        let replyAllAction = createReplyAllAction(cell: cell)
igor@1242
   273
        let forwardAction = createForwardAction(cell: cell)
igor@1242
   274
        let markAction = createMarkAction()
igor@1242
   275
        alertControler.addAction(cancelAction)
igor@1242
   276
        alertControler.addAction(replyAction)
xavier@1620
   277
        alertControler.addAction(replyAllAction)
igor@1242
   278
        alertControler.addAction(forwardAction)
igor@1242
   279
        alertControler.addAction(markAction)
igor@1414
   280
        if let popoverPresentationController = alertControler.popoverPresentationController {
igor@1414
   281
            popoverPresentationController.sourceView = cell
igor@1414
   282
        }
igor@1242
   283
        present(alertControler, animated: true, completion: nil)
igor@1242
   284
    }
xavier@1623
   285
igor@1242
   286
    // MARK: - Action Sheet Actions
igor@1242
   287
igor@1242
   288
    func createCancelAction() -> UIAlertAction {
xavier@1623
   289
        return  UIAlertAction(title: "Cancel", style: .cancel) { (action) in}
igor@1242
   290
    }
xavier@1623
   291
igor@1242
   292
    func createReplyAction(cell: EmailListViewCell) ->  UIAlertAction {
igor@1242
   293
        return UIAlertAction(title: "Reply", style: .default) { (action) in
xavier@1623
   294
            // self.performSegue(withIdentifier: self.segueCompose, sender: cell)
igor@1338
   295
            self.performSegue(withIdentifier: .segueCompose, sender: cell)
igor@1242
   296
        }
igor@1242
   297
    }
xavier@1620
   298
xavier@1620
   299
    func createReplyAllAction(cell: EmailListViewCell) ->  UIAlertAction {
xavier@1623
   300
        return UIAlertAction(title: "Reply All", style: .default) { (action) in
xavier@1623
   301
            self.performSegue(withIdentifier: .segueReplyAll, sender: cell)
xavier@1620
   302
        }
xavier@1620
   303
    }
xavier@1620
   304
igor@1242
   305
    func createForwardAction(cell: EmailListViewCell) -> UIAlertAction {
igor@1242
   306
        return UIAlertAction(title: "Forward", style: .default) { (action) in
igor@1338
   307
            //self.performSegue(withIdentifier: self.segueCompose, sender: cell)
xavier@1664
   308
            self.performSegue(withIdentifier: .segueForward, sender: cell)
igor@1242
   309
        }
igor@1242
   310
    }
xavier@1623
   311
igor@1242
   312
    func createMarkAction() -> UIAlertAction {
igor@1242
   313
        return UIAlertAction(title: "Mark", style: .default) { (action) in
igor@1242
   314
        }
igor@1242
   315
    }
xavier@1623
   316
igor@1301
   317
    // MARK: - Content Search
xavier@1623
   318
igor@1301
   319
    func filterContentForSearchText(searchText: String) {
xavier@1623
   320
igor@1301
   321
    }
xavier@1623
   322
dirk@784
   323
}
igor@1301
   324
igor@1301
   325
extension EmailListViewController: UISearchResultsUpdating, UISearchControllerDelegate {
igor@1301
   326
    public func updateSearchResults(for searchController: UISearchController) {
igor@1301
   327
        filterContentForSearchText(searchText: searchController.searchBar.text!)
igor@1301
   328
    }
xavier@1623
   329
igor@1301
   330
    func didDismissSearchController(_ searchController: UISearchController) {
igor@1301
   331
    }
igor@1301
   332
}
igor@1338
   333
igor@1338
   334
// MARK: - Navigation
igor@1338
   335
igor@1338
   336
extension EmailListViewController: SegueHandlerType {
xavier@1623
   337
igor@1338
   338
    // MARK: - SegueHandlerType
xavier@1623
   339
igor@1338
   340
    enum SegueIdentifier: String {
igor@1338
   341
        case segueAddNewAccount
igor@1338
   342
        case segueEditAccounts
igor@1338
   343
        case segueShowEmail
igor@1338
   344
        case segueCompose
xavier@1623
   345
        case segueReplyAll
xavier@1664
   346
        case segueForward
xavier@1865
   347
        case segueFilter
igor@1338
   348
        case noSegue
igor@1338
   349
    }
xavier@1623
   350
igor@1338
   351
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
igor@1338
   352
        switch segueIdentifier(for: segue) {
xavier@1623
   353
        case .segueReplyAll:
xavier@1623
   354
            if let nav = segue.destination as? UINavigationController,
xavier@1623
   355
                let destination = nav.topViewController as? ComposeTableViewController,
xavier@1623
   356
                let cell = sender as? EmailListViewCell,
xavier@1623
   357
                let indexPath = self.tableView.indexPath(for: cell),
xavier@1623
   358
                let email = cell.messageAt(indexPath: indexPath, config: config) {
xavier@1623
   359
                destination.composeMode = .replyAll
xavier@1623
   360
                destination.appConfig = config?.appConfig
xavier@1623
   361
                destination.originalMessage = email
xavier@1623
   362
            }
igor@1338
   363
            break
igor@1338
   364
        case .segueShowEmail:
dirk@1594
   365
            if let vc = segue.destination as? EmailViewController,
igor@1338
   366
                let cell = sender as? EmailListViewCell,
igor@1338
   367
                let indexPath = self.tableView.indexPath(for: cell),
dirk@1594
   368
                let email = cell.messageAt(indexPath: indexPath, config: config) {
xavier@1623
   369
                vc.appConfig = config?.appConfig
xavier@1623
   370
                vc.message = email
igor@1338
   371
            }
igor@1338
   372
            break
xavier@1664
   373
        case .segueForward:
xavier@1664
   374
            if let nav = segue.destination as? UINavigationController,
xavier@1664
   375
                let destination = nav.topViewController as? ComposeTableViewController,
xavier@1664
   376
                let cell = sender as? EmailListViewCell,
xavier@1664
   377
                let indexPath = self.tableView.indexPath(for: cell),
xavier@1664
   378
                let email = cell.messageAt(indexPath: indexPath, config: config) {
xavier@1664
   379
                destination.composeMode = .forward
xavier@1664
   380
                destination.appConfig = config?.appConfig
xavier@1664
   381
                destination.originalMessage = email
xavier@1664
   382
            }
xavier@1664
   383
            break
xavier@1865
   384
        case .segueFilter:
xavier@1865
   385
            if let destiny = segue.destination as? FilterTableViewController {
xavier@1865
   386
                destiny.filterDelegate = self
xavier@1865
   387
                destiny.inFolder = false
xavier@1876
   388
                destiny.filterEnabled = self.config?.folder?.filter as! Filter?
xavier@1865
   389
            }
xavier@1865
   390
            break
dirk@1694
   391
        case .segueAddNewAccount, .segueEditAccounts, .segueCompose, .noSegue:
dirk@1694
   392
            break
igor@1338
   393
        }
xavier@1865
   394
igor@1338
   395
    }
dirk@1350
   396
dirk@1350
   397
    func didChangeInternal(messageFolder: MessageFolder) {
dirk@1350
   398
        if let folder = config?.folder,
dirk@1350
   399
            let message = messageFolder as? Message,
dirk@1558
   400
            folder.contains(message: message, deletedMessagesAreContained: true) {
dirk@1350
   401
            if let msg = messageFolder as? Message {
dirk@1350
   402
                if msg.isOriginal {
dirk@1535
   403
                    // new message has arrived
dirk@1675
   404
                    if let index = folder.indexOf(message: msg) {
dirk@1675
   405
                        let ip = IndexPath(row: index, section: 0)
dirk@1737
   406
                        Log.info(
dirk@1737
   407
                            component: #function,
dirk@1737
   408
                            content: "insert message at \(index), \(folder.messageCount()) messages")
dirk@1675
   409
                        tableView.insertRows(at: [ip], with: .automatic)
dirk@1675
   410
                    } else {
dirk@1675
   411
                        tableView.reloadData()
dirk@1675
   412
                    }
dirk@1558
   413
                } else if msg.isGhost {
dirk@1737
   414
                    if let cell = cellFor(message: msg), let ip = tableView.indexPath(for: cell) {
dirk@1737
   415
                        Log.info(
dirk@1737
   416
                            component: #function,
dirk@1737
   417
                            content: "delete message at \(index), \(folder.messageCount()) messages")
dirk@1737
   418
                        tableView.deleteRows(at: [ip], with: .automatic)
dirk@1737
   419
                    } else {
dirk@1737
   420
                        tableView.reloadData()
dirk@1558
   421
                    }
dirk@1535
   422
                } else {
dirk@1558
   423
                    // other flags than delete must have been changed
dirk@1737
   424
                    if let cell = cellFor(message: msg) {
dirk@1542
   425
                        cell.updateFlags(message: message)
dirk@1737
   426
                    } else {
dirk@1737
   427
                        tableView.reloadData()
dirk@1542
   428
                    }
dirk@1350
   429
                }
dirk@1350
   430
            }
dirk@1350
   431
        }
dirk@1350
   432
    }
dirk@1737
   433
dirk@1737
   434
    // MARK: - Message -> Cell association
dirk@1737
   435
dirk@1737
   436
    func keyFor(message: Message) -> NSString {
dirk@1737
   437
        let parentName = message.parent?.name ?? "unknown"
dirk@1737
   438
        return "\(message.uuid) \(parentName) \(message.uuid)" as NSString
dirk@1737
   439
    }
dirk@1737
   440
dirk@1737
   441
    func associate(message: Message, toCell: EmailListViewCell) {
dirk@1737
   442
        cellsInUse.setObject(toCell, forKey: keyFor(message: message))
dirk@1737
   443
    }
dirk@1737
   444
dirk@1737
   445
    func cellFor(message: Message) -> EmailListViewCell? {
dirk@1737
   446
        return cellsInUse.object(forKey: keyFor(message: message))
dirk@1737
   447
    }
igor@1338
   448
}
dirk@1348
   449
dirk@1348
   450
// MARK: - MessageFolderDelegate
dirk@1348
   451
dirk@1348
   452
extension EmailListViewController: MessageFolderDelegate {
dirk@1348
   453
    func didChange(messageFolder: MessageFolder) {
dirk@1675
   454
        GCD.onMainWait {
dirk@1350
   455
            self.didChangeInternal(messageFolder: messageFolder)
dirk@1348
   456
        }
dirk@1348
   457
    }
dirk@1348
   458
}