blob: 0febf3f04597a7c149fc83fda066157d9abfad44 [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 <accountmodel.h>
30#import <callmodel.h>
31#import <account.h>
Alexandre Lision91d11e52015-03-20 17:42:05 -040032#import <call.h>
Alexandre Lision0f66bd32016-01-18 11:30:45 -050033#import <recentmodel.h>
Kateryna Kostiuk312f9132017-04-18 12:09:06 -040034#import <AvailableAccountModel.h>
Anthony Léonard79597602017-11-13 15:47:09 -050035#import <api/lrc.h>
Anthony Léonard49cb2912017-11-13 16:15:39 -050036#import <api/account.h>
Alexandre Lision5855b6a2015-02-03 11:31:05 -050037
Alexandre Lision624b1a82016-09-11 19:29:01 -040038// Ring
Alexandre Lision745e4d62015-03-22 20:03:10 -040039#import "AppDelegate.h"
Alexandre Lisionc65310c2015-04-23 16:44:23 -040040#import "Constants.h"
Alexandre Lision58cab672015-06-09 15:25:40 -040041#import "CurrentCallVC.h"
Alexandre Lision624b1a82016-09-11 19:29:01 -040042#import "MigrateRingAccountsWC.h"
Alexandre Lision0f66bd32016-01-18 11:30:45 -050043#import "ConversationVC.h"
Alexandre Lisionbfa68f62015-09-10 08:38:42 -040044#import "PreferencesWC.h"
Alexandre Lisiona3a43dc2017-03-30 16:21:30 -040045#import "SmartViewVC.h"
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -040046#import "views/IconButton.h"
Alexandre Lisionbfa68f62015-09-10 08:38:42 -040047#import "views/NSColor+RingTheme.h"
Alexandre Lisione77f6f92016-04-17 23:39:39 -040048#import "views/BackgroundView.h"
Kateryna Kostiuk13b76882017-03-30 09:18:44 -040049#import "ChooseAccountVC.h"
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -040050#import "ContactRequestVC.h"
Kateryna Kostiuk882cbac2017-07-05 17:29:00 -040051#import "PersonsVC.h"
Alexandre Lision2db8f472015-07-22 15:05:46 -040052
Kateryna Kostiuk13b76882017-03-30 09:18:44 -040053@interface RingWindowController () <MigrateRingAccountsDelegate, NSToolbarDelegate>
Alexandre Lision624b1a82016-09-11 19:29:01 -040054
55@property (retain) MigrateRingAccountsWC* migrateWC;
56
57@end
58
Alexandre Lisionbfa68f62015-09-10 08:38:42 -040059@implementation RingWindowController {
Alexandre Lision5855b6a2015-02-03 11:31:05 -050060
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -040061 __unsafe_unretained IBOutlet NSLayoutConstraint* centerYQRCodeConstraint;
62 __unsafe_unretained IBOutlet NSLayoutConstraint* centerYWelcomeContainerConstraint;
63 __unsafe_unretained IBOutlet NSView* welcomeContainer;
Alexandre Lision1abdf582016-02-09 14:21:19 -050064 __unsafe_unretained IBOutlet NSView* callView;
65 __unsafe_unretained IBOutlet NSTextField* ringIDLabel;
66 __unsafe_unretained IBOutlet NSButton* shareButton;
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -040067 __unsafe_unretained IBOutlet NSImageView* qrcodeView;
Alexandre Lision58cab672015-06-09 15:25:40 -040068
Anthony Léonard79597602017-11-13 15:47:09 -050069 std::unique_ptr<lrc::api::Lrc> lrc_;
70
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -040071 PreferencesWC* preferencesWC;
Alexandre Lisiona3a43dc2017-03-30 16:21:30 -040072 IBOutlet SmartViewVC* smartViewVC;
Kateryna Kostiuk882cbac2017-07-05 17:29:00 -040073 IBOutlet PersonsVC* personsVC;
Alexandre Lisione77f6f92016-04-17 23:39:39 -040074
Alexandre Lision0f66bd32016-01-18 11:30:45 -050075 CurrentCallVC* currentCallVC;
76 ConversationVC* offlineVC;
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -040077 // toolbar menu items
Kateryna Kostiuk13b76882017-03-30 09:18:44 -040078 ChooseAccountVC* chooseAccountVC;
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -040079 ContactRequestVC* contactRequestVC;
Alexandre Lisionbfa68f62015-09-10 08:38:42 -040080}
Alexandre Lision58cab672015-06-09 15:25:40 -040081
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -040082static NSString* const kPreferencesIdentifier = @"PreferencesIdentifier";
83NSString* const kChangeAccountToolBarItemIdentifier = @"ChangeAccountToolBarItemIdentifier";
84NSString* const kTrustRequestMenuItemIdentifier = @"TrustRequestMenuItemIdentifier";
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];
96 offlineVC = [[ConversationVC alloc] initWithNibName:@"Conversation" bundle:nil];
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -040097 // toolbar items
Anthony Léonard49cb2912017-11-13 16:15:39 -050098 chooseAccountVC = [[ChooseAccountVC alloc] initWithNibName:@"ChooseAccount" bundle:nil model:&(lrc_->getAccountModel())];
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -040099 contactRequestVC = [[ContactRequestVC alloc] initWithNibName:@"ContactRequest" bundle:nil];
Alexandre Lision58cab672015-06-09 15:25:40 -0400100 [callView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500101 [[currentCallVC view] setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
102 [[offlineVC view] setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
Alexandre Lision58cab672015-06-09 15:25:40 -0400103
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500104 [callView addSubview:[currentCallVC view] positioned:NSWindowAbove relativeTo:nil];
105 [callView addSubview:[offlineVC view] positioned:NSWindowAbove relativeTo:nil];
Alexandre Lision16d9c0a2015-08-10 12:05:15 -0400106
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500107 [currentCallVC initFrame];
108 [offlineVC initFrame];
Alexandre Lisionbb5c2462015-07-30 12:55:37 -0400109
Anthony Léonard49cb2912017-11-13 16:15:39 -0500110 // Fresh run, we need to make sure RingID appears
111 [shareButton sendActionOn:NSLeftMouseDownMask];
112
113 [self updateRingID];
114 // display accounts to select
115 NSToolbar *toolbar = self.window.toolbar;
116 toolbar.delegate = self;
117 [toolbar insertItemWithItemIdentifier:kChangeAccountToolBarItemIdentifier atIndex:1];
118 [toolbar insertItemWithItemIdentifier:kTrustRequestMenuItemIdentifier atIndex:2];
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500119}
120
Anthony Léonard49cb2912017-11-13 16:15:39 -0500121// TODO: Reimplement with new LRC signals
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500122- (void) connect
123{
Alexandre Lisionbb5c2462015-07-30 12:55:37 -0400124 // Update Ring ID label based on account model changes
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500125 QObject::connect(RecentModel::instance().selectionModel(),
126 &QItemSelectionModel::currentChanged,
127 [=](const QModelIndex &current, const QModelIndex &previous) {
128 auto call = RecentModel::instance().getActiveCall(current);
Alexandre Lision261f1b92016-04-04 12:35:34 -0400129
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500130 if(!current.isValid()) {
Alexandre Lision01cf5e32016-01-21 15:54:30 -0500131 [offlineVC animateOut];
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500132 [currentCallVC animateOut];
Kateryna Kostiukabf4e272017-04-18 14:18:00 -0400133 [chooseAccountVC enable];
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500134 return;
135 }
136
137 if (!call) {
138 [currentCallVC animateOut];
139 [offlineVC animateIn];
Kateryna Kostiukabf4e272017-04-18 14:18:00 -0400140 [chooseAccountVC enable];
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500141 } else {
142 [currentCallVC animateIn];
Alexandre Lision01cf5e32016-01-21 15:54:30 -0500143 [offlineVC animateOut];
Kateryna Kostiukabf4e272017-04-18 14:18:00 -0400144 [chooseAccountVC disable];
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500145 }
146 });
Alexandre Lision210fe212016-01-27 11:15:13 -0500147
148 QObject::connect(CallModel::instance().selectionModel(),
149 &QItemSelectionModel::currentChanged,
150 [=](const QModelIndex &current, const QModelIndex &previous) {
151 if(!current.isValid()) {
152 return;
153 }
154
155 if (previous.isValid()) {
156 // We were already on a call
157 [currentCallVC animateOut];
Kateryna Kostiukabf4e272017-04-18 14:18:00 -0400158 [chooseAccountVC enable];
Alexandre Lision210fe212016-01-27 11:15:13 -0500159 } else {
160 // Make sure Conversation view hides when selecting a valid call
161 [currentCallVC animateIn];
162 [offlineVC animateOut];
Kateryna Kostiukabf4e272017-04-18 14:18:00 -0400163 [chooseAccountVC disable];
Alexandre Lision210fe212016-01-27 11:15:13 -0500164 }
165 });
Kateryna Kostiuk312f9132017-04-18 12:09:06 -0400166 QObject::connect(AvailableAccountModel::instance().selectionModel(),
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400167 &QItemSelectionModel::currentChanged,
Kateryna Kostiuk312f9132017-04-18 12:09:06 -0400168 [self](const QModelIndex& idx){
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400169 [self updateRingID];
Kateryna Kostiukabf4e272017-04-18 14:18:00 -0400170 [offlineVC animateOut];
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400171 });
Alexandre Lisionbb5c2462015-07-30 12:55:37 -0400172}
173
174/**
175 * Implement the necessary logic to choose which Ring ID to display.
176 * This tries to choose the "best" ID to show
177 */
178- (void) updateRingID
179{
Anthony Léonard49cb2912017-11-13 16:15:39 -0500180 auto& account = [chooseAccountVC selectedAccount];
Alexandre Lisionbb5c2462015-07-30 12:55:37 -0400181
182 [ringIDLabel setStringValue:@""];
Anthony Léonard49cb2912017-11-13 16:15:39 -0500183
184 if(account.profileInfo.type != lrc::api::profile::Type::RING) {
Kateryna Kostiuka7248462017-04-18 16:15:31 -0400185 self.hideRingID = YES;
Kateryna Kostiuk312f9132017-04-18 12:09:06 -0400186 return;
Alexandre Lisionbb5c2462015-07-30 12:55:37 -0400187 }
Kateryna Kostiuka7248462017-04-18 16:15:31 -0400188 self.hideRingID = NO;
Anthony Léonard49cb2912017-11-13 16:15:39 -0500189 auto& registeredName = account.registeredName;
190 auto& ringID = account.profileInfo.uri;
Kateryna Kostiuk65ba43e2017-03-30 15:10:04 -0400191 NSString* uriToDisplay = nullptr;
Anthony Léonard49cb2912017-11-13 16:15:39 -0500192 if (!registeredName.empty()) {
193 uriToDisplay = @(registeredName.c_str());
Alexandre Lision313427f2016-11-24 21:04:04 -0500194 } else {
Anthony Léonard49cb2912017-11-13 16:15:39 -0500195 uriToDisplay = @(ringID.c_str());
Alexandre Lision313427f2016-11-24 21:04:04 -0500196 }
Kateryna Kostiuk65ba43e2017-03-30 15:10:04 -0400197 [ringIDLabel setStringValue:uriToDisplay];
Anthony Léonard49cb2912017-11-13 16:15:39 -0500198 [self drawQRCode:@(ringID.c_str())];
Alexandre Lision5855b6a2015-02-03 11:31:05 -0500199}
200
Alexandre Lision1abdf582016-02-09 14:21:19 -0500201- (IBAction)shareRingID:(id)sender {
202 NSSharingServicePicker* sharingServicePicker = [[NSSharingServicePicker alloc] initWithItems:[NSArray arrayWithObject:[ringIDLabel stringValue]]];
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400203 [sharingServicePicker setDelegate:self];
Alexandre Lision1abdf582016-02-09 14:21:19 -0500204 [sharingServicePicker showRelativeToRect:[sender bounds]
205 ofView:sender
206 preferredEdge:NSMinYEdge];
207}
208
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400209- (IBAction)toggleQRCode:(id)sender {
210 // Toggle pressed state of QRCode button
211 [sender setPressed:![sender isPressed]];
Kateryna Kostiuk65ba43e2017-03-30 15:10:04 -0400212 [self showQRCode:[sender isPressed]];
Alexandre Lision313427f2016-11-24 21:04:04 -0500213}
214
215/**
216 * Draw the QRCode in the qrCodeView
217 */
Kateryna Kostiuk65ba43e2017-03-30 15:10:04 -0400218- (void)drawQRCode:(NSString*) uriToDraw
Alexandre Lision313427f2016-11-24 21:04:04 -0500219{
Kateryna Kostiuk65ba43e2017-03-30 15:10:04 -0400220 auto qrCode = QRcode_encodeString(uriToDraw.UTF8String,
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400221 0,
222 QR_ECLEVEL_L, // Lowest level of error correction
223 QR_MODE_8, // 8-bit data mode
224 1);
225 if (!qrCode) {
226 return;
227 }
228
Alexandre Lision313427f2016-11-24 21:04:04 -0500229 unsigned char *data = 0;
230 int width;
231 data = qrCode->data;
232 width = qrCode->width;
233 int qr_margin = 3;
234
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400235 CGFloat size = qrcodeView.frame.size.width;
236
237 // create context
238 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
239 CGContextRef ctx = CGBitmapContextCreate(0, size, size, 8, size * 4, colorSpace, kCGImageAlphaPremultipliedLast);
240
241 CGAffineTransform translateTransform = CGAffineTransformMakeTranslation(0, -size);
242 CGAffineTransform scaleTransform = CGAffineTransformMakeScale(1, -1);
243 CGContextConcatCTM(ctx, CGAffineTransformConcat(translateTransform, scaleTransform));
244
Alexandre Lision313427f2016-11-24 21:04:04 -0500245 float zoom = ceil((double)size / (qrCode->width + 2.0 * qr_margin));
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400246 CGRect rectDraw = CGRectMake(0, 0, zoom, zoom);
247
248 int ran;
249 for(int i = 0; i < width; ++i) {
250 for(int j = 0; j < width; ++j) {
251 if(*data & 1) {
252 CGContextSetFillColorWithColor(ctx, [NSColor ringDarkGrey].CGColor);
253 rectDraw.origin = CGPointMake((j + qr_margin) * zoom,(i + qr_margin) * zoom);
254 CGContextAddRect(ctx, rectDraw);
255 CGContextFillPath(ctx);
256 } else {
257 CGContextSetFillColorWithColor(ctx, [NSColor windowBackgroundColor].CGColor);
258 rectDraw.origin = CGPointMake((j + qr_margin) * zoom,(i + qr_margin) * zoom);
259 CGContextAddRect(ctx, rectDraw);
260 CGContextFillPath(ctx);
261 }
262 ++data;
263 }
264 }
Alexandre Lision313427f2016-11-24 21:04:04 -0500265
266 // get image
267 auto qrCGImage = CGBitmapContextCreateImage(ctx);
268 auto qrImage = [[NSImage alloc] initWithCGImage:qrCGImage size:qrcodeView.frame.size];
269
270 // some releases
271 CGContextRelease(ctx);
272 CGImageRelease(qrCGImage);
273 CGColorSpaceRelease(colorSpace);
274 QRcode_free(qrCode);
275
276 [qrcodeView setImage:qrImage];
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400277}
278
279/**
280 * Start the in/out animation displaying the QRCode
281 * @param show should the QRCode be animated in or out
282 */
283- (void) showQRCode:(BOOL) show
284{
285 static const NSInteger offset = 110;
286 [NSAnimationContext beginGrouping];
287 NSAnimationContext.currentContext.duration = 0.5;
288 [[NSAnimationContext currentContext] setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
289 qrcodeView.animator.alphaValue = show ? 1.0 : 0.0;
290 [centerYQRCodeConstraint.animator setConstant: show ? offset : 0];
291 [centerYWelcomeContainerConstraint.animator setConstant:show ? -offset : 0];
292 [NSAnimationContext endGrouping];
293}
294
Alexandre Lision4a7b95e2015-02-20 10:06:43 -0500295- (IBAction)openPreferences:(id)sender
296{
Alexandre Lisionbfa68f62015-09-10 08:38:42 -0400297 preferencesWC = [[PreferencesWC alloc] initWithWindowNibName:@"PreferencesWindow"];
298 [preferencesWC.window makeKeyAndOrderFront:preferencesWC.window];
Alexandre Lision5855b6a2015-02-03 11:31:05 -0500299}
Alexandre Lision4a7b95e2015-02-20 10:06:43 -0500300
Kateryna Kostiuk882cbac2017-07-05 17:29:00 -0400301- (IBAction)callClickedAtRow:(id)sender
302{
303 NSTabViewItem *selectedTab = [smartViewVC.tabbar selectedTabViewItem];
304 int index = [smartViewVC.tabbar indexOfTabViewItem:selectedTab];
305 switch (index) {
306 case 0:
307 [smartViewVC startCallForRow:sender];
308 break;
309 case 2:
310 [personsVC startCallForRow:sender];
311 break;
312 default:
313 break;
314 }
315}
Alexandre Lision624b1a82016-09-11 19:29:01 -0400316#pragma mark - Ring account migration
317
318- (void) migrateRingAccount:(Account*) acc
319{
320 self.migrateWC = [[MigrateRingAccountsWC alloc] initWithDelegate:self actionCode:1];
321 self.migrateWC.account = acc;
322#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9
323 [self.window beginSheet:self.migrateWC.window completionHandler:nil];
324#else
325 [NSApp beginSheet: self.migrateWC.window
326 modalForWindow: self.window
327 modalDelegate: self
328 didEndSelector: nil
329 contextInfo: nil];
330#endif
331}
332
Anthony Léonard49cb2912017-11-13 16:15:39 -0500333// TODO: Reimplement as a blocking loop when new LRC models handle migration
Alexandre Lision624b1a82016-09-11 19:29:01 -0400334- (void)checkAccountsToMigrate
335{
336 auto ringList = AccountModel::instance().accountsToMigrate();
337 if (ringList.length() > 0){
338 Account* acc = ringList.value(0);
339 [self migrateRingAccount:acc];
340 } else {
341 // Fresh run, we need to make sure RingID appears
Alexandre Lision624b1a82016-09-11 19:29:01 -0400342 [shareButton sendActionOn:NSLeftMouseDownMask];
343
344 [self connect];
Kateryna Kostiuka7248462017-04-18 16:15:31 -0400345 [self updateRingID];
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400346 // display accounts to select
347 NSToolbar *toolbar = self.window.toolbar;
348 toolbar.delegate = self;
349 [toolbar insertItemWithItemIdentifier:kChangeAccountToolBarItemIdentifier atIndex:1];
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -0400350 [toolbar insertItemWithItemIdentifier:kTrustRequestMenuItemIdentifier atIndex:2];
Alexandre Lision624b1a82016-09-11 19:29:01 -0400351 }
352}
353
354- (void)migrationDidComplete
355{
356 [self checkAccountsToMigrate];
357}
358
359- (void)migrationDidCompleteWithError
360{
361 [self checkAccountsToMigrate];
362}
363
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400364#pragma mark - NSToolbarDelegate
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -0400365- (nullable NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
366{
367 if(itemIdentifier == kChangeAccountToolBarItemIdentifier) {
368 NSToolbarItem *toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:kChangeAccountToolBarItemIdentifier];
369 toolbarItem.view = chooseAccountVC.view;
370 return toolbarItem;
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400371 }
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -0400372 if(itemIdentifier == kTrustRequestMenuItemIdentifier) {
373 NSToolbarItem *toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:kTrustRequestMenuItemIdentifier];
374 toolbarItem.view = contactRequestVC.view;
375 return toolbarItem;
376 }
377 return nil;
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400378}
379
Alexandre Lision5855b6a2015-02-03 11:31:05 -0500380@end