From 834ca7fc4a2a13762c6cb8a6ddb7ce59814f184c Mon Sep 17 00:00:00 2001 From: Thinstuff Developer Date: Wed, 3 Apr 2013 09:36:55 +0200 Subject: [PATCH] iOS: Fixed issue where boookmarks were saved even though cancel was pressed --- client/common/CMakeLists.txt | 13 ------------- client/iOS/Controllers/BookmarkEditorController.h | 2 +- client/iOS/Controllers/BookmarkEditorController.m | 7 +++++-- client/iOS/Controllers/BookmarkListController.m | 16 +++++++++++++--- client/iOS/FreeRDP/ios_freerdp.m | 2 +- client/iOS/Models/Bookmark.h | 1 + client/iOS/Models/Bookmark.m | 7 +++++++ 7 files changed, 28 insertions(+), 20 deletions(-) diff --git a/client/common/CMakeLists.txt b/client/common/CMakeLists.txt index 1bb4e27..e249cd0 100644 --- a/client/common/CMakeLists.txt +++ b/client/common/CMakeLists.txt @@ -61,16 +61,3 @@ if(BUILD_TESTING) add_subdirectory(test) endif() -if(IOS AND MONOLITHIC_BUILD AND (NOT BUILD_SHARED_LIBS)) -# generate combined library - foreach(af ${${MODULE_PREFIX}_LIBS}) - get_target_property(LOC ${af} LOCATION) - if ((NOT (${LOC} MATCHES ".*libfreerdp.a$")) AND (NOT (${LOC} MATCHES ".*libwinpr.a$"))) - set(ALIST ${ALIST} ${LOC}) - endif() - endforeach() - get_target_property(LOC ${MODULE_NAME} LOCATION) - set(ALIST ${ALIST} ${LOC}) - message(${ALIST}) - add_custom_command(TARGET ${MODULE_NAME} POST_BUILD COMMAND libtool -static -o libfreerdp-client-combined.a ${ALIST}) -endif() diff --git a/client/iOS/Controllers/BookmarkEditorController.h b/client/iOS/Controllers/BookmarkEditorController.h index 1ca68d3..a2fdb15 100644 --- a/client/iOS/Controllers/BookmarkEditorController.h +++ b/client/iOS/Controllers/BookmarkEditorController.h @@ -17,7 +17,7 @@ @protocol BookmarkEditorDelegate // bookmark editing finsihed -- (void)commitBookmark:(ComputerBookmark*)bookmark; +- (void)commitBookmark:(ComputerBookmark*)bookmark replacingBookmark:(ComputerBookmark*)replacingBookmark; @end diff --git a/client/iOS/Controllers/BookmarkEditorController.m b/client/iOS/Controllers/BookmarkEditorController.m index de80c50..dc5714d 100644 --- a/client/iOS/Controllers/BookmarkEditorController.m +++ b/client/iOS/Controllers/BookmarkEditorController.m @@ -32,8 +32,11 @@ if ((self = [super initWithStyle:UITableViewStyleGrouped])) { // set additional settings state according to bookmark data - _bookmark = [bookmark retain]; - _params = [bookmark params]; + if ([[bookmark uuid] length] == 0) + _bookmark = [bookmark copy]; + else + _bookmark = [bookmark copyWithUUID]; + _params = [_bookmark params]; // if this is a TSX Connect bookmark - disable server settings if([_bookmark isKindOfClass:NSClassFromString(@"TSXConnectComputerBookmark")]) diff --git a/client/iOS/Controllers/BookmarkListController.m b/client/iOS/Controllers/BookmarkListController.m index b3f43c7..a6ff068 100644 --- a/client/iOS/Controllers/BookmarkListController.m +++ b/client/iOS/Controllers/BookmarkListController.m @@ -680,10 +680,20 @@ - (void)commitBookmark:(ComputerBookmark *)bookmark { - // if we got a manual bookmark that is not in the list yet - add it - if (![_manual_bookmarks containsObject:bookmark]) + // if we got a manual bookmark that is not in the list yet - add it otherwise replace it + BOOL found = NO; + for (int idx = 0; idx < [_manual_bookmarks count]; ++idx) + { + if ([[bookmark uuid] isEqualToString:[[_manual_bookmarks objectAtIndex:idx] uuid]]) + { + [_manual_bookmarks replaceObjectAtIndex:idx withObject:bookmark]; + found = YES; + break; + } + } + if (!found) [_manual_bookmarks addObject:bookmark]; - + // remove any quick connect history entry with the same hostname NSString* hostname = [[bookmark params] StringForKey:@"hostname"]; if ([_connection_history containsObject:hostname]) diff --git a/client/iOS/FreeRDP/ios_freerdp.m b/client/iOS/FreeRDP/ios_freerdp.m index ea9581f..ae3f1e0 100644 --- a/client/iOS/FreeRDP/ios_freerdp.m +++ b/client/iOS/FreeRDP/ios_freerdp.m @@ -99,7 +99,7 @@ static int ios_receive_channel_data(freerdp* instance, int channelId, UINT8* dat void ios_process_channel_event(rdpChannels* channels, freerdp* instance) { - RDP_EVENT* event = freerdp_channels_pop_event(channels); + wMessage* event = freerdp_channels_pop_event(channels); if (event) freerdp_event_free(event); } diff --git a/client/iOS/Models/Bookmark.h b/client/iOS/Models/Bookmark.h index 4594aa5..b66eac8 100644 --- a/client/iOS/Models/Bookmark.h +++ b/client/iOS/Models/Bookmark.h @@ -30,6 +30,7 @@ // Creates a copy of this object, with a new UUID - (id)copy; +- (id)copyWithUUID; // Whether user can delete, move, or rename this entry - (BOOL)isDeletable; diff --git a/client/iOS/Models/Bookmark.m b/client/iOS/Models/Bookmark.m index 2ce7903..2cdc6df 100644 --- a/client/iOS/Models/Bookmark.m +++ b/client/iOS/Models/Bookmark.m @@ -87,6 +87,13 @@ return copy; } +- (id)copyWithUUID +{ + ComputerBookmark* copy = [self copy]; + copy->_uuid = [[self uuid] copy]; + return copy; +} + - (void)encodeWithCoder:(NSCoder *)coder { if (![coder allowsKeyedCoding]) -- 2.7.4