Skip to content
Snippets Groups Projects
Commit 4ac4aeed authored by Edric Milaret's avatar Edric Milaret Committed by Alexandre Lision
Browse files

fix code style

Use clang-format Chromium style for Objective-C
Use Swimat for swift code
 - 4 Space indent
 - Remove break before opening brace

Change-Id: I4b38b37f07f3973ceaa81b02f56dd56a6592380e
Tuleap: #313
parent a68931d4
No related branches found
No related tags found
No related merge requests found
...@@ -110,7 +110,7 @@ struct Account { ...@@ -110,7 +110,7 @@ struct Account {
} }
set { set {
details["Account.enable"] = newValue.toString() details["Account.enable"] = newValue.toString()
ConfigurationManagerAdaptator.sharedManager().setAccountActive(self.id, newValue) ConfigurationManagerAdaptator.sharedManager().setAccountActive(self.id, active: newValue)
} }
} }
...@@ -157,6 +157,6 @@ struct Account { ...@@ -157,6 +157,6 @@ struct Account {
} }
func save() { func save() {
ConfigurationManagerAdaptator.sharedManager().setAccountDetails(id, details) ConfigurationManagerAdaptator.sharedManager().setAccountDetails(id, details: details)
} }
} }
\ No newline at end of file
...@@ -27,7 +27,6 @@ class AccountDetailsViewController: UIViewController { ...@@ -27,7 +27,6 @@ class AccountDetailsViewController: UIViewController {
@IBOutlet weak var detailsLabel: UILabel! @IBOutlet weak var detailsLabel: UILabel!
// MARK: - UIViewController // MARK: - UIViewController
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA.
*/ */
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
...@@ -30,10 +31,12 @@ ...@@ -30,10 +31,12 @@
- (NSMutableDictionary*)getAccountTemplate:(NSString*)accountType; - (NSMutableDictionary*)getAccountTemplate:(NSString*)accountType;
- (NSString*)addAccount:(NSDictionary*)details; - (NSString*)addAccount:(NSDictionary*)details;
- (void)removeAccount:(NSString*)accountID; - (void)removeAccount:(NSString*)accountID;
- (void) setAccountActive: (NSString*) accountID : (bool) active; - (void)setAccountActive:(NSString*)accountID active:(bool)active;
- (uint64_t) sendAccountTextMessage: (NSString*) accountID : (NSString*) to : (NSDictionary*) payloads; - (uint64_t)sendAccountTextMessage:(NSString*)accountID
to:(NSString*)to
payloads:(NSDictionary*)payloads;
- (NSDictionary*)getAccountDetails:(NSString*)accountID; - (NSDictionary*)getAccountDetails:(NSString*)accountID;
- (NSDictionary*)getVolatileAccountDetails:(NSString*)accountID; - (NSDictionary*)getVolatileAccountDetails:(NSString*)accountID;
- (void) setAccountDetails: (NSString*) accountID : (NSDictionary*) details; - (void)setAccountDetails:(NSString*)accountID details:(NSDictionary*)details;
- (int)getMessageStatus:(uint64_t)msgID; - (int)getMessageStatus:(uint64_t)msgID;
@end @end
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA.
*/ */
#import "ConfigurationManagerAdaptator.h" #import "ConfigurationManagerAdaptator.h"
...@@ -45,85 +46,86 @@ using namespace DRing; ...@@ -45,85 +46,86 @@ using namespace DRing;
return self; return self;
} }
- (NSArray*) getAccountList - (NSArray*)getAccountList {
{
auto accountVector = getAccountList(); auto accountVector = getAccountList();
return [Utils vectorToArray:accountVector]; return [Utils vectorToArray:accountVector];
} }
- (NSMutableDictionary*) getAccountTemplate: (NSString*) accountType - (NSMutableDictionary*)getAccountTemplate:(NSString*)accountType {
{ auto accountTemplate =
auto accountTemplate = getAccountTemplate(std::string([accountType UTF8String])); getAccountTemplate(std::string([accountType UTF8String]));
return [Utils mapToDictionnary:accountTemplate]; return [Utils mapToDictionnary:accountTemplate];
} }
- (NSString*) addAccount: (NSDictionary*) details - (NSString*)addAccount:(NSDictionary*)details {
{
auto accountID = addAccount([Utils dictionnaryToMap:details]); auto accountID = addAccount([Utils dictionnaryToMap:details]);
return [NSString stringWithUTF8String:accountID.c_str()]; return [NSString stringWithUTF8String:accountID.c_str()];
} }
- (void) removeAccount: (NSString*) accountID - (void)removeAccount:(NSString*)accountID {
{
removeAccount(std::string([accountID UTF8String])); removeAccount(std::string([accountID UTF8String]));
} }
- (void) setAccountActive: (NSString*) accountID : (bool) active - (void)setAccountActive:(NSString*)accountID active:(bool)active {
{
setAccountActive(std::string([accountID UTF8String]), active); setAccountActive(std::string([accountID UTF8String]), active);
} }
- (uint64_t) sendAccountTextMessage: (NSString*) accountID : (NSString*) to : (NSDictionary*) payloads - (uint64_t)sendAccountTextMessage:(NSString*)accountID
{ to:(NSString*)to
return sendAccountTextMessage(std::string([accountID UTF8String]), std::string([to UTF8String]), payloads:(NSDictionary*)payloads {
return sendAccountTextMessage(std::string([accountID UTF8String]),
std::string([to UTF8String]),
[Utils dictionnaryToMap:payloads]); [Utils dictionnaryToMap:payloads]);
} }
- (NSDictionary*) getAccountDetails: (NSString*) accountID - (NSDictionary*)getAccountDetails:(NSString*)accountID {
{
auto accDetails = getAccountDetails(std::string([accountID UTF8String])); auto accDetails = getAccountDetails(std::string([accountID UTF8String]));
return [Utils mapToDictionnary:accDetails]; return [Utils mapToDictionnary:accDetails];
} }
- (NSDictionary*) getVolatileAccountDetails: (NSString*) accountID - (NSDictionary*)getVolatileAccountDetails:(NSString*)accountID {
{ auto volatileDetails =
auto volatileDetails = getVolatileAccountDetails(std::string([accountID UTF8String])); getVolatileAccountDetails(std::string([accountID UTF8String]));
return [Utils mapToDictionnary:volatileDetails]; return [Utils mapToDictionnary:volatileDetails];
} }
- (void) setAccountDetails: (NSString*) accountID : (NSDictionary*) details - (void)setAccountDetails:(NSString*)accountID details:(NSDictionary*)details {
{ setAccountDetails(std::string([accountID UTF8String]),
setAccountDetails(std::string([accountID UTF8String]), [Utils dictionnaryToMap:details]); [Utils dictionnaryToMap:details]);
} }
- (int) getMessageStatus:(uint64_t) msgID - (int)getMessageStatus:(uint64_t)msgID {
{
return getMessageStatus(msgID); return getMessageStatus(msgID);
} }
- (void) registerConfigurationHandler - (void)registerConfigurationHandler {
{
std::map<std::string, std::shared_ptr<CallbackWrapperBase>> confHandlers; std::map<std::string, std::shared_ptr<CallbackWrapperBase>> confHandlers;
confHandlers.insert(exportable_callback<ConfigurationSignal::IncomingAccountMessage>( confHandlers.insert(
[&](const std::string& account_id, exportable_callback<ConfigurationSignal::IncomingAccountMessage>(
const std::string& from, [&](const std::string& account_id, const std::string& from,
const std::map<std::string, std::string>& payloads) { const std::map<std::string, std::string>& payloads) {
NSDictionary* userInfo = @{@"accountID": [NSString stringWithUTF8String:account_id.c_str()], NSDictionary* userInfo = @{
@"accountID" : [NSString stringWithUTF8String:account_id.c_str()],
@"from" : [NSString stringWithUTF8String:from.c_str()], @"from" : [NSString stringWithUTF8String:from.c_str()],
@"payloads": [Utils mapToDictionnary:payloads]}; @"payloads" : [Utils mapToDictionnary:payloads]
};
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName:@"IncomingAccountMessage" object:self userInfo:userInfo]; [nc postNotificationName:@"IncomingAccountMessage"
object:self
userInfo:userInfo];
})); }));
confHandlers.insert(exportable_callback<ConfigurationSignal::AccountsChanged>([&](){ confHandlers.insert(
exportable_callback<ConfigurationSignal::AccountsChanged>([&]() {
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName:@"AccountsChanged" object:[ConfigurationManagerAdaptator sharedManager]]; [nc postNotificationName:@"AccountsChanged"
object:[ConfigurationManagerAdaptator sharedManager]];
})); }));
registerConfHandlers(confHandlers); registerConfHandlers(confHandlers);
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA.
*/ */
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
...@@ -27,4 +28,3 @@ ...@@ -27,4 +28,3 @@
- (void)pollEvents; - (void)pollEvents;
- (nonnull NSString*)getVersion; - (nonnull NSString*)getVersion;
@end @end
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA.
*/ */
#import "DRingAdaptator.h" #import "DRingAdaptator.h"
...@@ -24,29 +25,24 @@ ...@@ -24,29 +25,24 @@
@implementation DRingAdaptator @implementation DRingAdaptator
- (BOOL) initDaemon - (BOOL)initDaemon {
{
int flag = DRing::DRING_FLAG_CONSOLE_LOG | DRing::DRING_FLAG_DEBUG; int flag = DRing::DRING_FLAG_CONSOLE_LOG | DRing::DRING_FLAG_DEBUG;
return DRing::init(static_cast<DRing::InitFlag>(flag)); return DRing::init(static_cast<DRing::InitFlag>(flag));
} }
- (BOOL) startDaemon - (BOOL)startDaemon {
{
return DRing::start(); return DRing::start();
} }
- (void) fini - (void)fini {
{
DRing::fini(); DRing::fini();
} }
- (void) pollEvents - (void)pollEvents {
{
DRing::pollEvents(); DRing::pollEvents();
} }
- (NSString*)getVersion - (NSString*)getVersion {
{
return [NSString stringWithUTF8String:DRing::version()]; return [NSString stringWithUTF8String:DRing::version()];
} }
......
...@@ -15,13 +15,14 @@ ...@@ -15,13 +15,14 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA.
*/ */
// //
// Use this file to import your target's public headers that you would like to expose to Swift. // Use this file to import your target's public headers that you would like to
// expose to Swift.
// //
#import "DRingAdaptator.h"
#import "ConfigurationManagerAdaptator.h" #import "ConfigurationManagerAdaptator.h"
#import "DRingAdaptator.h"
\ No newline at end of file
...@@ -15,19 +15,21 @@ ...@@ -15,19 +15,21 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA.
*/ */
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <map>
#import <string> #import <string>
#import <vector> #import <vector>
#import <map>
@interface Utils : NSObject @interface Utils : NSObject
+ (NSArray*)vectorToArray:(const std::vector<std::string>&)vector; + (NSArray*)vectorToArray:(const std::vector<std::string>&)vector;
+ (NSMutableDictionary*) mapToDictionnary: (const std::map<std::string, std::string>&) map; + (NSMutableDictionary*)mapToDictionnary:
(const std::map<std::string, std::string>&)map;
+ (std::map<std::string, std::string>)dictionnaryToMap:(NSDictionary*)dict; + (std::map<std::string, std::string>)dictionnaryToMap:(NSDictionary*)dict;
@end @end
...@@ -15,15 +15,15 @@ ...@@ -15,15 +15,15 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA.
*/ */
#import "Utils.h" #import "Utils.h"
@implementation Utils @implementation Utils
+ (NSArray*) vectorToArray: (const std::vector<std::string>&) vector + (NSArray*)vectorToArray:(const std::vector<std::string>&)vector {
{
NSMutableArray* resArray = [NSMutableArray new]; NSMutableArray* resArray = [NSMutableArray new];
std::for_each(vector.begin(), vector.end(), ^(std::string str) { std::for_each(vector.begin(), vector.end(), ^(std::string str) {
id nsstr = [NSString stringWithUTF8String:str.c_str()]; id nsstr = [NSString stringWithUTF8String:str.c_str()];
...@@ -32,11 +32,12 @@ ...@@ -32,11 +32,12 @@
return resArray; return resArray;
} }
+ (NSMutableDictionary*) mapToDictionnary: (const std::map<std::string, std::string>&) map + (NSMutableDictionary*)mapToDictionnary:
{ (const std::map<std::string, std::string>&)map {
NSMutableDictionary* resDictionnary = [NSMutableDictionary new]; NSMutableDictionary* resDictionnary = [NSMutableDictionary new];
std::for_each(map.begin(), map.end(), ^(std::pair<std::string, std::string> keyValue) { std::for_each(
map.begin(), map.end(), ^(std::pair<std::string, std::string> keyValue) {
id key = [NSString stringWithUTF8String:keyValue.first.c_str()]; id key = [NSString stringWithUTF8String:keyValue.first.c_str()];
id value = [NSString stringWithUTF8String:keyValue.second.c_str()]; id value = [NSString stringWithUTF8String:keyValue.second.c_str()];
[resDictionnary setObject:value forKey:key]; [resDictionnary setObject:value forKey:key];
...@@ -45,11 +46,12 @@ ...@@ -45,11 +46,12 @@
return resDictionnary; return resDictionnary;
} }
+ (std::map<std::string, std::string>) dictionnaryToMap: (NSDictionary*) dict + (std::map<std::string, std::string>)dictionnaryToMap:(NSDictionary*)dict {
{
std::map<std::string, std::string> resMap; std::map<std::string, std::string> resMap;
for (id key in dict) for (id key in dict)
resMap.insert(std::pair<std::string, std::string>(std::string([key UTF8String]), std::string([[dict objectForKey:key] UTF8String]))); resMap.insert(std::pair<std::string, std::string>(
std::string([key UTF8String]),
std::string([[dict objectForKey:key] UTF8String])));
return resMap; return resMap;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment