blob: 853e4e64f20b0ab71a20459fd593bb5d12e6769f [file] [log] [blame]
Alexandre Lision8521baa2015-03-13 11:08:00 -04001/*
Alexandre Lision9fe374b2016-01-06 10:17:31 -05002 * Copyright (C) 2015-2016 Savoir-faire Linux Inc.
Alexandre Lision8521baa2015-03-13 11:08:00 -04003 * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Alexandre Lision8521baa2015-03-13 11:08:00 -040018 */
Alexandre Lision5855b6a2015-02-03 11:31:05 -050019#import "RingWindowController.h"
Alexandre Lision0f66bd32016-01-18 11:30:45 -050020#import <QuartzCore/QuartzCore.h>
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -040021#include <qrencode.h>
Anthony Léonard79597602017-11-13 15:47:09 -050022#include <memory>
Alexandre Lision0f66bd32016-01-18 11:30:45 -050023
24//Qt
25#import <QItemSelectionModel>
26#import <QItemSelection>
Alexandre Lision5855b6a2015-02-03 11:31:05 -050027
Alexandre Lisionbb5c2462015-07-30 12:55:37 -040028//LRC
Alexandre Lision5855b6a2015-02-03 11:31:05 -050029#import <callmodel.h>
30#import <account.h>
Alexandre Lision91d11e52015-03-20 17:42:05 -040031#import <call.h>
Alexandre Lision0f66bd32016-01-18 11:30:45 -050032#import <recentmodel.h>
Kateryna Kostiuk312f9132017-04-18 12:09:06 -040033#import <AvailableAccountModel.h>
Anthony Léonard79597602017-11-13 15:47:09 -050034#import <api/lrc.h>
Anthony Léonard49cb2912017-11-13 16:15:39 -050035#import <api/account.h>
Olivier Soldano994971f2017-12-05 16:30:12 -050036#import <api/newaccountmodel.h>
37#import <api/newcallmodel.h>
38#import <api/behaviorcontroller.h>
39#import <api/conversation.h>
Anthony Léonardd00cd182018-01-17 09:21:27 -050040#import <api/contactmodel.h>
41#import <api/contact.h>
Alexandre Lision5855b6a2015-02-03 11:31:05 -050042
Alexandre Lision624b1a82016-09-11 19:29:01 -040043// Ring
Alexandre Lision745e4d62015-03-22 20:03:10 -040044#import "AppDelegate.h"
Alexandre Lisionc65310c2015-04-23 16:44:23 -040045#import "Constants.h"
Alexandre Lision58cab672015-06-09 15:25:40 -040046#import "CurrentCallVC.h"
Alexandre Lision624b1a82016-09-11 19:29:01 -040047#import "MigrateRingAccountsWC.h"
Alexandre Lision0f66bd32016-01-18 11:30:45 -050048#import "ConversationVC.h"
Alexandre Lisionbfa68f62015-09-10 08:38:42 -040049#import "PreferencesWC.h"
Alexandre Lisiona3a43dc2017-03-30 16:21:30 -040050#import "SmartViewVC.h"
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -040051#import "views/IconButton.h"
Alexandre Lisionbfa68f62015-09-10 08:38:42 -040052#import "views/NSColor+RingTheme.h"
Alexandre Lisione77f6f92016-04-17 23:39:39 -040053#import "views/BackgroundView.h"
Kateryna Kostiuk13b76882017-03-30 09:18:44 -040054#import "ChooseAccountVC.h"
Alexandre Lision2db8f472015-07-22 15:05:46 -040055
Kateryna Kostiuk13b76882017-03-30 09:18:44 -040056@interface RingWindowController () <MigrateRingAccountsDelegate, NSToolbarDelegate>
Alexandre Lision624b1a82016-09-11 19:29:01 -040057
58@property (retain) MigrateRingAccountsWC* migrateWC;
59
60@end
61
Alexandre Lisionbfa68f62015-09-10 08:38:42 -040062@implementation RingWindowController {
Alexandre Lision5855b6a2015-02-03 11:31:05 -050063
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -040064 __unsafe_unretained IBOutlet NSLayoutConstraint* centerYQRCodeConstraint;
65 __unsafe_unretained IBOutlet NSLayoutConstraint* centerYWelcomeContainerConstraint;
66 __unsafe_unretained IBOutlet NSView* welcomeContainer;
Alexandre Lision1abdf582016-02-09 14:21:19 -050067 __unsafe_unretained IBOutlet NSView* callView;
68 __unsafe_unretained IBOutlet NSTextField* ringIDLabel;
69 __unsafe_unretained IBOutlet NSButton* shareButton;
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -040070 __unsafe_unretained IBOutlet NSImageView* qrcodeView;
Alexandre Lision58cab672015-06-09 15:25:40 -040071
Anthony Léonard79597602017-11-13 15:47:09 -050072 std::unique_ptr<lrc::api::Lrc> lrc_;
73
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -040074 PreferencesWC* preferencesWC;
Alexandre Lisiona3a43dc2017-03-30 16:21:30 -040075 IBOutlet SmartViewVC* smartViewVC;
Alexandre Lisione77f6f92016-04-17 23:39:39 -040076
Alexandre Lision0f66bd32016-01-18 11:30:45 -050077 CurrentCallVC* currentCallVC;
78 ConversationVC* offlineVC;
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -040079 // toolbar menu items
Kateryna Kostiuk13b76882017-03-30 09:18:44 -040080 ChooseAccountVC* chooseAccountVC;
Alexandre Lisionbfa68f62015-09-10 08:38:42 -040081}
Alexandre Lision58cab672015-06-09 15:25:40 -040082
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -040083static NSString* const kPreferencesIdentifier = @"PreferencesIdentifier";
84NSString* const kChangeAccountToolBarItemIdentifier = @"ChangeAccountToolBarItemIdentifier";
Alexandre Lisionc5148052015-03-04 15:10:35 -050085
Alexandre Lision5855b6a2015-02-03 11:31:05 -050086- (void)windowDidLoad {
87 [super windowDidLoad];
Alexandre Lision4dfcafc2015-08-20 12:43:23 -040088 [self.window setMovableByWindowBackground:YES];
Alexandre Lision58cab672015-06-09 15:25:40 -040089
Alexandre Lisione77f6f92016-04-17 23:39:39 -040090 [self.window setBackgroundColor:[NSColor colorWithRed:242.0/255 green:242.0/255 blue:242.0/255 alpha:1.0]];
Kateryna Kostiuk13b76882017-03-30 09:18:44 -040091 self.window.titleVisibility = NSWindowTitleHidden;
Alexandre Lisione77f6f92016-04-17 23:39:39 -040092
Anthony Léonard79597602017-11-13 15:47:09 -050093 lrc_ = std::make_unique<lrc::api::Lrc>();
94
Alexandre Lision0f66bd32016-01-18 11:30:45 -050095 currentCallVC = [[CurrentCallVC alloc] initWithNibName:@"CurrentCall" bundle:nil];
Anthony Léonard8585cc02017-12-28 14:03:45 -050096 offlineVC = [[ConversationVC alloc] initWithNibName:@"Conversation" bundle:nil delegate:self];
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -040097 // toolbar items
Anthony Léonard9bebf1d2017-12-21 14:33:51 -050098 chooseAccountVC = [[ChooseAccountVC alloc] initWithNibName:@"ChooseAccount" bundle:nil model:&(lrc_->getAccountModel()) delegate:self];
Alexandre Lision58cab672015-06-09 15:25:40 -040099 [callView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500100 [[currentCallVC view] setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
101 [[offlineVC view] setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
Alexandre Lision58cab672015-06-09 15:25:40 -0400102
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500103 [callView addSubview:[currentCallVC view] positioned:NSWindowAbove relativeTo:nil];
104 [callView addSubview:[offlineVC view] positioned:NSWindowAbove relativeTo:nil];
Alexandre Lision16d9c0a2015-08-10 12:05:15 -0400105
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500106 [currentCallVC initFrame];
107 [offlineVC initFrame];
Anthony Léonard72128c92017-12-26 16:48:39 -0500108 @try {
109 [smartViewVC setConversationModel: [chooseAccountVC selectedAccount].conversationModel.get()];
110 }
111 @catch (NSException *ex) {
112 NSLog(@"Caught exception %@: %@", [ex name], [ex reason]);
113 }
Alexandre Lisionbb5c2462015-07-30 12:55:37 -0400114
Anthony Léonard49cb2912017-11-13 16:15:39 -0500115 // Fresh run, we need to make sure RingID appears
116 [shareButton sendActionOn:NSLeftMouseDownMask];
117
Olivier Soldano994971f2017-12-05 16:30:12 -0500118 [self connect];
Anthony Léonard49cb2912017-11-13 16:15:39 -0500119 [self updateRingID];
120 // display accounts to select
121 NSToolbar *toolbar = self.window.toolbar;
122 toolbar.delegate = self;
123 [toolbar insertItemWithItemIdentifier:kChangeAccountToolBarItemIdentifier atIndex:1];
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500124}
125
126- (void) connect
127{
Olivier Soldano994971f2017-12-05 16:30:12 -0500128 QObject::connect(&lrc_->getBehaviorController(),
129 &lrc::api::BehaviorController::showCallView,
130 [self](const std::string accountId,
131 const lrc::api::conversation::Info convInfo){
132 auto* accInfo = &lrc_->getAccountModel().getAccountInfo(accountId);
Anthony Léonardd00cd182018-01-17 09:21:27 -0500133 if (accInfo->contactModel->getContact(convInfo.participants[0]).profileInfo.type == lrc::api::profile::Type::PENDING)
134 [smartViewVC selectPendingList];
135 else
136 [smartViewVC selectConversationList];
137
Olivier Soldano994971f2017-12-05 16:30:12 -0500138 [currentCallVC setCurrentCall:convInfo.callId
139 conversation:convInfo.uid
140 account:accInfo];
Anthony Léonard9bebf1d2017-12-21 14:33:51 -0500141 [smartViewVC selectConversation: convInfo model:accInfo->conversationModel.get()];
Olivier Soldano994971f2017-12-05 16:30:12 -0500142 [currentCallVC animateIn];
143 [offlineVC animateOut];
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500144 });
Alexandre Lision210fe212016-01-27 11:15:13 -0500145
Olivier Soldano994971f2017-12-05 16:30:12 -0500146 QObject::connect(&lrc_->getBehaviorController(),
147 &lrc::api::BehaviorController::showIncomingCallView,
148 [self](const std::string accountId,
149 const lrc::api::conversation::Info convInfo){
150 auto* accInfo = &lrc_->getAccountModel().getAccountInfo(accountId);
Anthony Léonardd00cd182018-01-17 09:21:27 -0500151 if (accInfo->contactModel->getContact(convInfo.participants[0]).profileInfo.type == lrc::api::profile::Type::PENDING)
152 [smartViewVC selectPendingList];
153 else
154 [smartViewVC selectConversationList];
155
Olivier Soldano994971f2017-12-05 16:30:12 -0500156 [currentCallVC setCurrentCall:convInfo.callId
157 conversation:convInfo.uid
158 account:accInfo];
Anthony Léonard9bebf1d2017-12-21 14:33:51 -0500159 [smartViewVC selectConversation: convInfo model:accInfo->conversationModel.get()];
Olivier Soldano994971f2017-12-05 16:30:12 -0500160 [currentCallVC animateIn];
Kateryna Kostiukabf4e272017-04-18 14:18:00 -0400161 [offlineVC animateOut];
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400162 });
Anthony Léonard2382b562017-12-13 15:51:28 -0500163
164 QObject::connect(&lrc_->getBehaviorController(),
165 &lrc::api::BehaviorController::showChatView,
166 [self](const std::string& accountId,
167 const lrc::api::conversation::Info& convInfo){
168 auto& accInfo = lrc_->getAccountModel().getAccountInfo(accountId);
169 [offlineVC setConversationUid:convInfo.uid model:accInfo.conversationModel.get()];
Anthony Léonard9bebf1d2017-12-21 14:33:51 -0500170 [smartViewVC selectConversation: convInfo model:accInfo.conversationModel.get()];
Anthony Léonard2382b562017-12-13 15:51:28 -0500171 [offlineVC animateIn];
172 [currentCallVC animateOut];
173 });
Alexandre Lisionbb5c2462015-07-30 12:55:37 -0400174}
175
176/**
177 * Implement the necessary logic to choose which Ring ID to display.
178 * This tries to choose the "best" ID to show
179 */
180- (void) updateRingID
181{
Anthony Léonard72128c92017-12-26 16:48:39 -0500182 @try {
183 auto& account = [chooseAccountVC selectedAccount];
Alexandre Lisionbb5c2462015-07-30 12:55:37 -0400184
Anthony Léonard72128c92017-12-26 16:48:39 -0500185 [ringIDLabel setStringValue:@""];
Anthony Léonard49cb2912017-11-13 16:15:39 -0500186
Anthony Léonard72128c92017-12-26 16:48:39 -0500187 if(account.profileInfo.type != lrc::api::profile::Type::RING) {
188 self.hideRingID = YES;
189 return;
190 }
191 self.hideRingID = NO;
192 auto& registeredName = account.registeredName;
193 auto& ringID = account.profileInfo.uri;
194 NSString* uriToDisplay = nullptr;
195 if (!registeredName.empty()) {
196 uriToDisplay = @(registeredName.c_str());
197 } else {
198 uriToDisplay = @(ringID.c_str());
199 }
200 [ringIDLabel setStringValue:uriToDisplay];
201 [self drawQRCode:@(ringID.c_str())];
Alexandre Lisionbb5c2462015-07-30 12:55:37 -0400202 }
Anthony Léonard72128c92017-12-26 16:48:39 -0500203 @catch (NSException *ex) {
204 NSLog(@"Caught exception %@: %@", [ex name], [ex reason]);
205 self.hideRingID = NO;
206 [ringIDLabel setStringValue:@"No account available"];
Alexandre Lision313427f2016-11-24 21:04:04 -0500207 }
Alexandre Lision5855b6a2015-02-03 11:31:05 -0500208}
209
Alexandre Lision1abdf582016-02-09 14:21:19 -0500210- (IBAction)shareRingID:(id)sender {
211 NSSharingServicePicker* sharingServicePicker = [[NSSharingServicePicker alloc] initWithItems:[NSArray arrayWithObject:[ringIDLabel stringValue]]];
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400212 [sharingServicePicker setDelegate:self];
Alexandre Lision1abdf582016-02-09 14:21:19 -0500213 [sharingServicePicker showRelativeToRect:[sender bounds]
214 ofView:sender
215 preferredEdge:NSMinYEdge];
216}
217
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400218- (IBAction)toggleQRCode:(id)sender {
219 // Toggle pressed state of QRCode button
220 [sender setPressed:![sender isPressed]];
Kateryna Kostiuk65ba43e2017-03-30 15:10:04 -0400221 [self showQRCode:[sender isPressed]];
Alexandre Lision313427f2016-11-24 21:04:04 -0500222}
223
224/**
225 * Draw the QRCode in the qrCodeView
226 */
Kateryna Kostiuk65ba43e2017-03-30 15:10:04 -0400227- (void)drawQRCode:(NSString*) uriToDraw
Alexandre Lision313427f2016-11-24 21:04:04 -0500228{
Kateryna Kostiuk65ba43e2017-03-30 15:10:04 -0400229 auto qrCode = QRcode_encodeString(uriToDraw.UTF8String,
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400230 0,
231 QR_ECLEVEL_L, // Lowest level of error correction
232 QR_MODE_8, // 8-bit data mode
233 1);
234 if (!qrCode) {
235 return;
236 }
237
Alexandre Lision313427f2016-11-24 21:04:04 -0500238 unsigned char *data = 0;
239 int width;
240 data = qrCode->data;
241 width = qrCode->width;
242 int qr_margin = 3;
243
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400244 CGFloat size = qrcodeView.frame.size.width;
245
246 // create context
247 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
248 CGContextRef ctx = CGBitmapContextCreate(0, size, size, 8, size * 4, colorSpace, kCGImageAlphaPremultipliedLast);
249
250 CGAffineTransform translateTransform = CGAffineTransformMakeTranslation(0, -size);
251 CGAffineTransform scaleTransform = CGAffineTransformMakeScale(1, -1);
252 CGContextConcatCTM(ctx, CGAffineTransformConcat(translateTransform, scaleTransform));
253
Alexandre Lision313427f2016-11-24 21:04:04 -0500254 float zoom = ceil((double)size / (qrCode->width + 2.0 * qr_margin));
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400255 CGRect rectDraw = CGRectMake(0, 0, zoom, zoom);
256
257 int ran;
258 for(int i = 0; i < width; ++i) {
259 for(int j = 0; j < width; ++j) {
260 if(*data & 1) {
261 CGContextSetFillColorWithColor(ctx, [NSColor ringDarkGrey].CGColor);
262 rectDraw.origin = CGPointMake((j + qr_margin) * zoom,(i + qr_margin) * zoom);
263 CGContextAddRect(ctx, rectDraw);
264 CGContextFillPath(ctx);
265 } else {
266 CGContextSetFillColorWithColor(ctx, [NSColor windowBackgroundColor].CGColor);
267 rectDraw.origin = CGPointMake((j + qr_margin) * zoom,(i + qr_margin) * zoom);
268 CGContextAddRect(ctx, rectDraw);
269 CGContextFillPath(ctx);
270 }
271 ++data;
272 }
273 }
Alexandre Lision313427f2016-11-24 21:04:04 -0500274
275 // get image
276 auto qrCGImage = CGBitmapContextCreateImage(ctx);
277 auto qrImage = [[NSImage alloc] initWithCGImage:qrCGImage size:qrcodeView.frame.size];
278
279 // some releases
280 CGContextRelease(ctx);
281 CGImageRelease(qrCGImage);
282 CGColorSpaceRelease(colorSpace);
283 QRcode_free(qrCode);
284
285 [qrcodeView setImage:qrImage];
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400286}
287
288/**
289 * Start the in/out animation displaying the QRCode
290 * @param show should the QRCode be animated in or out
291 */
292- (void) showQRCode:(BOOL) show
293{
294 static const NSInteger offset = 110;
295 [NSAnimationContext beginGrouping];
296 NSAnimationContext.currentContext.duration = 0.5;
297 [[NSAnimationContext currentContext] setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
298 qrcodeView.animator.alphaValue = show ? 1.0 : 0.0;
299 [centerYQRCodeConstraint.animator setConstant: show ? offset : 0];
300 [centerYWelcomeContainerConstraint.animator setConstant:show ? -offset : 0];
301 [NSAnimationContext endGrouping];
302}
303
Alexandre Lision4a7b95e2015-02-20 10:06:43 -0500304- (IBAction)openPreferences:(id)sender
305{
Alexandre Lisionbfa68f62015-09-10 08:38:42 -0400306 preferencesWC = [[PreferencesWC alloc] initWithWindowNibName:@"PreferencesWindow"];
307 [preferencesWC.window makeKeyAndOrderFront:preferencesWC.window];
Alexandre Lision5855b6a2015-02-03 11:31:05 -0500308}
Alexandre Lision4a7b95e2015-02-20 10:06:43 -0500309
Kateryna Kostiuk882cbac2017-07-05 17:29:00 -0400310- (IBAction)callClickedAtRow:(id)sender
311{
312 NSTabViewItem *selectedTab = [smartViewVC.tabbar selectedTabViewItem];
313 int index = [smartViewVC.tabbar indexOfTabViewItem:selectedTab];
314 switch (index) {
315 case 0:
316 [smartViewVC startCallForRow:sender];
317 break;
Kateryna Kostiuk882cbac2017-07-05 17:29:00 -0400318 default:
319 break;
320 }
321}
Anthony Léonard0a9904c2018-01-11 16:43:47 -0500322
Alexandre Lision624b1a82016-09-11 19:29:01 -0400323#pragma mark - Ring account migration
324
325- (void) migrateRingAccount:(Account*) acc
326{
327 self.migrateWC = [[MigrateRingAccountsWC alloc] initWithDelegate:self actionCode:1];
328 self.migrateWC.account = acc;
329#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9
330 [self.window beginSheet:self.migrateWC.window completionHandler:nil];
331#else
332 [NSApp beginSheet: self.migrateWC.window
333 modalForWindow: self.window
334 modalDelegate: self
335 didEndSelector: nil
336 contextInfo: nil];
337#endif
338}
339
Anthony Léonard49cb2912017-11-13 16:15:39 -0500340// TODO: Reimplement as a blocking loop when new LRC models handle migration
Alexandre Lision624b1a82016-09-11 19:29:01 -0400341- (void)checkAccountsToMigrate
342{
343 auto ringList = AccountModel::instance().accountsToMigrate();
344 if (ringList.length() > 0){
345 Account* acc = ringList.value(0);
346 [self migrateRingAccount:acc];
347 } else {
348 // Fresh run, we need to make sure RingID appears
Alexandre Lision624b1a82016-09-11 19:29:01 -0400349 [shareButton sendActionOn:NSLeftMouseDownMask];
350
351 [self connect];
Kateryna Kostiuka7248462017-04-18 16:15:31 -0400352 [self updateRingID];
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400353 // display accounts to select
354 NSToolbar *toolbar = self.window.toolbar;
355 toolbar.delegate = self;
356 [toolbar insertItemWithItemIdentifier:kChangeAccountToolBarItemIdentifier atIndex:1];
Alexandre Lision624b1a82016-09-11 19:29:01 -0400357 }
358}
359
360- (void)migrationDidComplete
361{
362 [self checkAccountsToMigrate];
363}
364
365- (void)migrationDidCompleteWithError
366{
367 [self checkAccountsToMigrate];
368}
369
Anthony Léonard9bebf1d2017-12-21 14:33:51 -0500370-(void)selectAccount:(const lrc::api::account::Info&)accInfo
371{
372 // If the selected account has been changed, we close any open panel
373 if ([smartViewVC setConversationModel:accInfo.conversationModel.get()]) {
374 [currentCallVC animateOut];
375 [offlineVC animateOut];
376 }
Anthony Léonard61e3dcf2017-12-27 12:19:52 -0500377
378 // Welcome view informations are also updated
379 [self updateRingID];
Anthony Léonard9bebf1d2017-12-21 14:33:51 -0500380}
381
Anthony Léonard8585cc02017-12-28 14:03:45 -0500382-(void)rightPanelClosed
383{
384 [smartViewVC deselect];
385}
386
Anthony Léonard0a9904c2018-01-11 16:43:47 -0500387-(void)currentConversationTrusted
388{
389 [smartViewVC selectConversationList];
390}
391
Anthony Léonardbee94cc2018-01-16 11:42:40 -0500392-(void) listTypeChanged {
393 [offlineVC animateOut];
394 [currentCallVC animateOut];
395}
396
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400397#pragma mark - NSToolbarDelegate
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -0400398- (nullable NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
399{
400 if(itemIdentifier == kChangeAccountToolBarItemIdentifier) {
401 NSToolbarItem *toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:kChangeAccountToolBarItemIdentifier];
402 toolbarItem.view = chooseAccountVC.view;
403 return toolbarItem;
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400404 }
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -0400405 return nil;
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400406}
407
Alexandre Lision5855b6a2015-02-03 11:31:05 -0500408@end