Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 13:58:55 +01:00
parent 4af19165ec
commit 68073add76
12458 changed files with 12350765 additions and 2 deletions

View file

@ -0,0 +1,5 @@
@interface MWMEditorHelper : NSObject
+ (void)uploadEdits:(void (^)(UIBackgroundFetchResult))completionHandler;
@end

View 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