Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
5
iphone/Maps/Core/Editor/MWMEditorHelper.h
Normal file
5
iphone/Maps/Core/Editor/MWMEditorHelper.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
@interface MWMEditorHelper : NSObject
|
||||
|
||||
+ (void)uploadEdits:(void (^)(UIBackgroundFetchResult))completionHandler;
|
||||
|
||||
@end
|
||||
50
iphone/Maps/Core/Editor/MWMEditorHelper.mm
Normal file
50
iphone/Maps/Core/Editor/MWMEditorHelper.mm
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#import "MWMEditorHelper.h"
|
||||
#import <CoreApi/AppInfo.h>
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <functional>
|
||||
#include "editor/osm_editor.hpp"
|
||||
|
||||
@implementation MWMEditorHelper
|
||||
|
||||
+ (void)uploadEdits:(void (^)(UIBackgroundFetchResult))completionHandler
|
||||
{
|
||||
if (!Profile.isExisting ||
|
||||
Platform::EConnectionType::CONNECTION_NONE == Platform::ConnectionStatus())
|
||||
{
|
||||
completionHandler(UIBackgroundFetchResultFailed);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto const lambda = [completionHandler](osm::Editor::UploadResult result) {
|
||||
switch (result)
|
||||
{
|
||||
case osm::Editor::UploadResult::Success:
|
||||
completionHandler(UIBackgroundFetchResultNewData);
|
||||
break;
|
||||
case osm::Editor::UploadResult::Error:
|
||||
completionHandler(UIBackgroundFetchResultFailed);
|
||||
break;
|
||||
case osm::Editor::UploadResult::NothingToUpload:
|
||||
completionHandler(UIBackgroundFetchResultNoData);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
NSString *authorizationToken = Profile.authorizationToken;
|
||||
if (authorizationToken == nil) {
|
||||
authorizationToken = @"";
|
||||
}
|
||||
std::string const oauthToken = std::string([authorizationToken UTF8String]);
|
||||
osm::Editor::Instance().UploadChanges(
|
||||
oauthToken,
|
||||
{{"created_by",
|
||||
std::string("CoMaps " OMIM_OS_NAME " ") + AppInfo.sharedInfo.bundleVersion.UTF8String},
|
||||
{"bundle_id", NSBundle.mainBundle.bundleIdentifier.UTF8String}},
|
||||
lambda);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Add table
Add a link
Reference in a new issue