blob: 8838ffff2daf328894218d358fc4d0261b7feb31 [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"
Alexandre Lision2db8f472015-07-22 15:05:46 -040051
Kateryna Kostiuk13b76882017-03-30 09:18:44 -040052@interface RingWindowController () <MigrateRingAccountsDelegate, NSToolbarDelegate>
Alexandre Lision624b1a82016-09-11 19:29:01 -040053
54@property (retain) MigrateRingAccountsWC* migrateWC;
55
56@end
57
Alexandre Lisionbfa68f62015-09-10 08:38:42 -040058@implementation RingWindowController {
Alexandre Lision5855b6a2015-02-03 11:31:05 -050059
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -040060 __unsafe_unretained IBOutlet NSLayoutConstraint* centerYQRCodeConstraint;
61 __unsafe_unretained IBOutlet NSLayoutConstraint* centerYWelcomeContainerConstraint;
62 __unsafe_unretained IBOutlet NSView* welcomeContainer;
Alexandre Lision1abdf582016-02-09 14:21:19 -050063 __unsafe_unretained IBOutlet NSView* callView;
64 __unsafe_unretained IBOutlet NSTextField* ringIDLabel;
65 __unsafe_unretained IBOutlet NSButton* shareButton;
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -040066 __unsafe_unretained IBOutlet NSImageView* qrcodeView;
Alexandre Lision58cab672015-06-09 15:25:40 -040067
Anthony Léonard79597602017-11-13 15:47:09 -050068 std::unique_ptr<lrc::api::Lrc> lrc_;
69
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -040070 PreferencesWC* preferencesWC;
Alexandre Lisiona3a43dc2017-03-30 16:21:30 -040071 IBOutlet SmartViewVC* smartViewVC;
Alexandre Lisione77f6f92016-04-17 23:39:39 -040072
Alexandre Lision0f66bd32016-01-18 11:30:45 -050073 CurrentCallVC* currentCallVC;
74 ConversationVC* offlineVC;
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -040075 // toolbar menu items
Kateryna Kostiuk13b76882017-03-30 09:18:44 -040076 ChooseAccountVC* chooseAccountVC;
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -040077 ContactRequestVC* contactRequestVC;
Alexandre Lisionbfa68f62015-09-10 08:38:42 -040078}
Alexandre Lision58cab672015-06-09 15:25:40 -040079
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -040080static NSString* const kPreferencesIdentifier = @"PreferencesIdentifier";
81NSString* const kChangeAccountToolBarItemIdentifier = @"ChangeAccountToolBarItemIdentifier";
82NSString* const kTrustRequestMenuItemIdentifier = @"TrustRequestMenuItemIdentifier";
Alexandre Lisionc5148052015-03-04 15:10:35 -050083
Alexandre Lision5855b6a2015-02-03 11:31:05 -050084- (void)windowDidLoad {
85 [super windowDidLoad];
Alexandre Lision4dfcafc2015-08-20 12:43:23 -040086 [self.window setMovableByWindowBackground:YES];
Alexandre Lision58cab672015-06-09 15:25:40 -040087
Alexandre Lisione77f6f92016-04-17 23:39:39 -040088 [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 -040089 self.window.titleVisibility = NSWindowTitleHidden;
Alexandre Lisione77f6f92016-04-17 23:39:39 -040090
Anthony Léonard79597602017-11-13 15:47:09 -050091 lrc_ = std::make_unique<lrc::api::Lrc>();
92
Alexandre Lision0f66bd32016-01-18 11:30:45 -050093 currentCallVC = [[CurrentCallVC alloc] initWithNibName:@"CurrentCall" bundle:nil];
94 offlineVC = [[ConversationVC alloc] initWithNibName:@"Conversation" bundle:nil];
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -040095 // toolbar items
Anthony Léonard49cb2912017-11-13 16:15:39 -050096 chooseAccountVC = [[ChooseAccountVC alloc] initWithNibName:@"ChooseAccount" bundle:nil model:&(lrc_->getAccountModel())];
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -040097 contactRequestVC = [[ContactRequestVC alloc] initWithNibName:@"ContactRequest" bundle:nil];
Alexandre Lision58cab672015-06-09 15:25:40 -040098 [callView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
Alexandre Lision0f66bd32016-01-18 11:30:45 -050099 [[currentCallVC view] setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
100 [[offlineVC view] setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
Alexandre Lision58cab672015-06-09 15:25:40 -0400101
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500102 [callView addSubview:[currentCallVC view] positioned:NSWindowAbove relativeTo:nil];
103 [callView addSubview:[offlineVC view] positioned:NSWindowAbove relativeTo:nil];
Alexandre Lision16d9c0a2015-08-10 12:05:15 -0400104
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500105 [currentCallVC initFrame];
106 [offlineVC initFrame];
Olivier Soldanod4311552017-11-20 15:09:53 -0500107 [smartViewVC setConversationModel: [chooseAccountVC selectedAccount].conversationModel.get()];
Alexandre Lisionbb5c2462015-07-30 12:55:37 -0400108
Anthony Léonard49cb2912017-11-13 16:15:39 -0500109 // Fresh run, we need to make sure RingID appears
110 [shareButton sendActionOn:NSLeftMouseDownMask];
111
112 [self updateRingID];
113 // display accounts to select
114 NSToolbar *toolbar = self.window.toolbar;
115 toolbar.delegate = self;
116 [toolbar insertItemWithItemIdentifier:kChangeAccountToolBarItemIdentifier atIndex:1];
117 [toolbar insertItemWithItemIdentifier:kTrustRequestMenuItemIdentifier atIndex:2];
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500118}
119
Anthony Léonard49cb2912017-11-13 16:15:39 -0500120// TODO: Reimplement with new LRC signals
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500121- (void) connect
122{
Alexandre Lisionbb5c2462015-07-30 12:55:37 -0400123 // Update Ring ID label based on account model changes
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500124 QObject::connect(RecentModel::instance().selectionModel(),
125 &QItemSelectionModel::currentChanged,
126 [=](const QModelIndex &current, const QModelIndex &previous) {
127 auto call = RecentModel::instance().getActiveCall(current);
Alexandre Lision261f1b92016-04-04 12:35:34 -0400128
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500129 if(!current.isValid()) {
Alexandre Lision01cf5e32016-01-21 15:54:30 -0500130 [offlineVC animateOut];
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500131 [currentCallVC animateOut];
Kateryna Kostiukabf4e272017-04-18 14:18:00 -0400132 [chooseAccountVC enable];
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500133 return;
134 }
135
136 if (!call) {
137 [currentCallVC animateOut];
138 [offlineVC animateIn];
Kateryna Kostiukabf4e272017-04-18 14:18:00 -0400139 [chooseAccountVC enable];
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500140 } else {
141 [currentCallVC animateIn];
Alexandre Lision01cf5e32016-01-21 15:54:30 -0500142 [offlineVC animateOut];
Kateryna Kostiukabf4e272017-04-18 14:18:00 -0400143 [chooseAccountVC disable];
Alexandre Lision0f66bd32016-01-18 11:30:45 -0500144 }
145 });
Alexandre Lision210fe212016-01-27 11:15:13 -0500146
147 QObject::connect(CallModel::instance().selectionModel(),
148 &QItemSelectionModel::currentChanged,
149 [=](const QModelIndex &current, const QModelIndex &previous) {
150 if(!current.isValid()) {
151 return;
152 }
153
154 if (previous.isValid()) {
155 // We were already on a call
156 [currentCallVC animateOut];
Kateryna Kostiukabf4e272017-04-18 14:18:00 -0400157 [chooseAccountVC enable];
Alexandre Lision210fe212016-01-27 11:15:13 -0500158 } else {
159 // Make sure Conversation view hides when selecting a valid call
160 [currentCallVC animateIn];
161 [offlineVC animateOut];
Kateryna Kostiukabf4e272017-04-18 14:18:00 -0400162 [chooseAccountVC disable];
Alexandre Lision210fe212016-01-27 11:15:13 -0500163 }
164 });
Kateryna Kostiuk312f9132017-04-18 12:09:06 -0400165 QObject::connect(AvailableAccountModel::instance().selectionModel(),
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400166 &QItemSelectionModel::currentChanged,
Kateryna Kostiuk312f9132017-04-18 12:09:06 -0400167 [self](const QModelIndex& idx){
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400168 [self updateRingID];
Kateryna Kostiukabf4e272017-04-18 14:18:00 -0400169 [offlineVC animateOut];
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400170 });
Alexandre Lisionbb5c2462015-07-30 12:55:37 -0400171}
172
173/**
174 * Implement the necessary logic to choose which Ring ID to display.
175 * This tries to choose the "best" ID to show
176 */
177- (void) updateRingID
178{
Anthony Léonard49cb2912017-11-13 16:15:39 -0500179 auto& account = [chooseAccountVC selectedAccount];
Alexandre Lisionbb5c2462015-07-30 12:55:37 -0400180
181 [ringIDLabel setStringValue:@""];
Anthony Léonard49cb2912017-11-13 16:15:39 -0500182
183 if(account.profileInfo.type != lrc::api::profile::Type::RING) {
Kateryna Kostiuka7248462017-04-18 16:15:31 -0400184 self.hideRingID = YES;
Kateryna Kostiuk312f9132017-04-18 12:09:06 -0400185 return;
Alexandre Lisionbb5c2462015-07-30 12:55:37 -0400186 }
Kateryna Kostiuka7248462017-04-18 16:15:31 -0400187 self.hideRingID = NO;
Anthony Léonard49cb2912017-11-13 16:15:39 -0500188 auto& registeredName = account.registeredName;
189 auto& ringID = account.profileInfo.uri;
Kateryna Kostiuk65ba43e2017-03-30 15:10:04 -0400190 NSString* uriToDisplay = nullptr;
Anthony Léonard49cb2912017-11-13 16:15:39 -0500191 if (!registeredName.empty()) {
192 uriToDisplay = @(registeredName.c_str());
Alexandre Lision313427f2016-11-24 21:04:04 -0500193 } else {
Anthony Léonard49cb2912017-11-13 16:15:39 -0500194 uriToDisplay = @(ringID.c_str());
Alexandre Lision313427f2016-11-24 21:04:04 -0500195 }
Kateryna Kostiuk65ba43e2017-03-30 15:10:04 -0400196 [ringIDLabel setStringValue:uriToDisplay];
Anthony Léonard49cb2912017-11-13 16:15:39 -0500197 [self drawQRCode:@(ringID.c_str())];
Alexandre Lision5855b6a2015-02-03 11:31:05 -0500198}
199
Alexandre Lision1abdf582016-02-09 14:21:19 -0500200- (IBAction)shareRingID:(id)sender {
201 NSSharingServicePicker* sharingServicePicker = [[NSSharingServicePicker alloc] initWithItems:[NSArray arrayWithObject:[ringIDLabel stringValue]]];
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400202 [sharingServicePicker setDelegate:self];
Alexandre Lision1abdf582016-02-09 14:21:19 -0500203 [sharingServicePicker showRelativeToRect:[sender bounds]
204 ofView:sender
205 preferredEdge:NSMinYEdge];
206}
207
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400208- (IBAction)toggleQRCode:(id)sender {
209 // Toggle pressed state of QRCode button
210 [sender setPressed:![sender isPressed]];
Kateryna Kostiuk65ba43e2017-03-30 15:10:04 -0400211 [self showQRCode:[sender isPressed]];
Alexandre Lision313427f2016-11-24 21:04:04 -0500212}
213
214/**
215 * Draw the QRCode in the qrCodeView
216 */
Kateryna Kostiuk65ba43e2017-03-30 15:10:04 -0400217- (void)drawQRCode:(NSString*) uriToDraw
Alexandre Lision313427f2016-11-24 21:04:04 -0500218{
Kateryna Kostiuk65ba43e2017-03-30 15:10:04 -0400219 auto qrCode = QRcode_encodeString(uriToDraw.UTF8String,
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400220 0,
221 QR_ECLEVEL_L, // Lowest level of error correction
222 QR_MODE_8, // 8-bit data mode
223 1);
224 if (!qrCode) {
225 return;
226 }
227
Alexandre Lision313427f2016-11-24 21:04:04 -0500228 unsigned char *data = 0;
229 int width;
230 data = qrCode->data;
231 width = qrCode->width;
232 int qr_margin = 3;
233
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400234 CGFloat size = qrcodeView.frame.size.width;
235
236 // create context
237 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
238 CGContextRef ctx = CGBitmapContextCreate(0, size, size, 8, size * 4, colorSpace, kCGImageAlphaPremultipliedLast);
239
240 CGAffineTransform translateTransform = CGAffineTransformMakeTranslation(0, -size);
241 CGAffineTransform scaleTransform = CGAffineTransformMakeScale(1, -1);
242 CGContextConcatCTM(ctx, CGAffineTransformConcat(translateTransform, scaleTransform));
243
Alexandre Lision313427f2016-11-24 21:04:04 -0500244 float zoom = ceil((double)size / (qrCode->width + 2.0 * qr_margin));
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400245 CGRect rectDraw = CGRectMake(0, 0, zoom, zoom);
246
247 int ran;
248 for(int i = 0; i < width; ++i) {
249 for(int j = 0; j < width; ++j) {
250 if(*data & 1) {
251 CGContextSetFillColorWithColor(ctx, [NSColor ringDarkGrey].CGColor);
252 rectDraw.origin = CGPointMake((j + qr_margin) * zoom,(i + qr_margin) * zoom);
253 CGContextAddRect(ctx, rectDraw);
254 CGContextFillPath(ctx);
255 } else {
256 CGContextSetFillColorWithColor(ctx, [NSColor windowBackgroundColor].CGColor);
257 rectDraw.origin = CGPointMake((j + qr_margin) * zoom,(i + qr_margin) * zoom);
258 CGContextAddRect(ctx, rectDraw);
259 CGContextFillPath(ctx);
260 }
261 ++data;
262 }
263 }
Alexandre Lision313427f2016-11-24 21:04:04 -0500264
265 // get image
266 auto qrCGImage = CGBitmapContextCreateImage(ctx);
267 auto qrImage = [[NSImage alloc] initWithCGImage:qrCGImage size:qrcodeView.frame.size];
268
269 // some releases
270 CGContextRelease(ctx);
271 CGImageRelease(qrCGImage);
272 CGColorSpaceRelease(colorSpace);
273 QRcode_free(qrCode);
274
275 [qrcodeView setImage:qrImage];
Alexandre Lisionfd0d6c82016-03-29 17:06:54 -0400276}
277
278/**
279 * Start the in/out animation displaying the QRCode
280 * @param show should the QRCode be animated in or out
281 */
282- (void) showQRCode:(BOOL) show
283{
284 static const NSInteger offset = 110;
285 [NSAnimationContext beginGrouping];
286 NSAnimationContext.currentContext.duration = 0.5;
287 [[NSAnimationContext currentContext] setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
288 qrcodeView.animator.alphaValue = show ? 1.0 : 0.0;
289 [centerYQRCodeConstraint.animator setConstant: show ? offset : 0];
290 [centerYWelcomeContainerConstraint.animator setConstant:show ? -offset : 0];
291 [NSAnimationContext endGrouping];
292}
293
Alexandre Lision4a7b95e2015-02-20 10:06:43 -0500294- (IBAction)openPreferences:(id)sender
295{
Alexandre Lisionbfa68f62015-09-10 08:38:42 -0400296 preferencesWC = [[PreferencesWC alloc] initWithWindowNibName:@"PreferencesWindow"];
297 [preferencesWC.window makeKeyAndOrderFront:preferencesWC.window];
Alexandre Lision5855b6a2015-02-03 11:31:05 -0500298}
Alexandre Lision4a7b95e2015-02-20 10:06:43 -0500299
Kateryna Kostiuk882cbac2017-07-05 17:29:00 -0400300- (IBAction)callClickedAtRow:(id)sender
301{
302 NSTabViewItem *selectedTab = [smartViewVC.tabbar selectedTabViewItem];
303 int index = [smartViewVC.tabbar indexOfTabViewItem:selectedTab];
304 switch (index) {
305 case 0:
306 [smartViewVC startCallForRow:sender];
307 break;
Kateryna Kostiuk882cbac2017-07-05 17:29:00 -0400308 default:
309 break;
310 }
311}
Alexandre Lision624b1a82016-09-11 19:29:01 -0400312#pragma mark - Ring account migration
313
314- (void) migrateRingAccount:(Account*) acc
315{
316 self.migrateWC = [[MigrateRingAccountsWC alloc] initWithDelegate:self actionCode:1];
317 self.migrateWC.account = acc;
318#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9
319 [self.window beginSheet:self.migrateWC.window completionHandler:nil];
320#else
321 [NSApp beginSheet: self.migrateWC.window
322 modalForWindow: self.window
323 modalDelegate: self
324 didEndSelector: nil
325 contextInfo: nil];
326#endif
327}
328
Anthony Léonard49cb2912017-11-13 16:15:39 -0500329// TODO: Reimplement as a blocking loop when new LRC models handle migration
Alexandre Lision624b1a82016-09-11 19:29:01 -0400330- (void)checkAccountsToMigrate
331{
332 auto ringList = AccountModel::instance().accountsToMigrate();
333 if (ringList.length() > 0){
334 Account* acc = ringList.value(0);
335 [self migrateRingAccount:acc];
336 } else {
337 // Fresh run, we need to make sure RingID appears
Alexandre Lision624b1a82016-09-11 19:29:01 -0400338 [shareButton sendActionOn:NSLeftMouseDownMask];
339
340 [self connect];
Kateryna Kostiuka7248462017-04-18 16:15:31 -0400341 [self updateRingID];
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400342 // display accounts to select
343 NSToolbar *toolbar = self.window.toolbar;
344 toolbar.delegate = self;
345 [toolbar insertItemWithItemIdentifier:kChangeAccountToolBarItemIdentifier atIndex:1];
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -0400346 [toolbar insertItemWithItemIdentifier:kTrustRequestMenuItemIdentifier atIndex:2];
Alexandre Lision624b1a82016-09-11 19:29:01 -0400347 }
348}
349
350- (void)migrationDidComplete
351{
352 [self checkAccountsToMigrate];
353}
354
355- (void)migrationDidCompleteWithError
356{
357 [self checkAccountsToMigrate];
358}
359
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400360#pragma mark - NSToolbarDelegate
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -0400361- (nullable NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
362{
363 if(itemIdentifier == kChangeAccountToolBarItemIdentifier) {
364 NSToolbarItem *toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:kChangeAccountToolBarItemIdentifier];
365 toolbarItem.view = chooseAccountVC.view;
366 return toolbarItem;
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400367 }
Kateryna Kostiukdb1f3a12017-04-24 12:08:28 -0400368 if(itemIdentifier == kTrustRequestMenuItemIdentifier) {
369 NSToolbarItem *toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:kTrustRequestMenuItemIdentifier];
370 toolbarItem.view = contactRequestVC.view;
371 return toolbarItem;
372 }
373 return nil;
Kateryna Kostiuk13b76882017-03-30 09:18:44 -0400374}
375
Alexandre Lision5855b6a2015-02-03 11:31:05 -0500376@end