linphone-ios/Classes/HistoryDetailsTableView.m
Gautier Pelloux-Prayer 2c05f973c0 major mv
2015-09-09 16:44:00 +02:00

55 lines
1.6 KiB
Objective-C

//
// HistoryDetailsTableViewController.m
// linphone
//
// Created by Gautier Pelloux-Prayer on 27/07/15.
//
//
#import "HistoryDetailsTableView.h"
#import "LinphoneManager.h"
#import "Utils.h"
@implementation HistoryDetailsTableView
- (void)loadData {
if (callLogs == nil) {
callLogs = [[NSMutableArray alloc] init];
} else {
[callLogs removeAllObjects];
}
const MSList *logs = linphone_core_get_call_logs([LinphoneManager getLc]);
while (logs != NULL) {
LinphoneCallLog *log = (LinphoneCallLog *)logs->data;
[callLogs addObject:[NSValue valueWithPointer:log]];
logs = ms_list_next(logs);
}
[[self tableView] reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [callLogs count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *kCellId = @"UITableViewCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId];
if (cell == nil) {
cell = [[UITableViewCell alloc] init];
}
LinphoneCallLog *log = [[callLogs objectAtIndex:[indexPath row]] pointerValue];
int duration = linphone_call_log_get_duration(log);
time_t callTime = linphone_call_log_get_start_date(log);
cell.textLabel.textAlignment = NSTextAlignmentCenter;
[cell.textLabel
setText:[NSString stringWithFormat:@"%@ - %d sec",
[LinphoneUtils timeToString:callTime withStyle:NSDateFormatterMediumStyle],
duration]];
return cell;
}
@end