Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 57 additions & 53 deletions WordPress/Classes/Models/Blog.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#import <CoreData/CoreData.h>
#import "JetpackState.h"

NS_ASSUME_NONNULL_BEGIN

@class BlogSettings;
@class WPAccount;
@class WordPressComApi;
Expand Down Expand Up @@ -54,53 +56,53 @@ typedef NS_ENUM(NSInteger, SiteVisibility) {

@interface Blog : NSManagedObject

@property (nonatomic, strong, readwrite) NSNumber *blogID __deprecated_msg("Use dotComID instead");
@property (nonatomic, strong, readwrite) NSNumber *dotComID;
@property (nonatomic, strong, readwrite) NSString *xmlrpc;
@property (nonatomic, strong, readwrite) NSString *apiKey;
@property (nonatomic, strong, readwrite) NSNumber *hasOlderPosts;
@property (nonatomic, strong, readwrite) NSNumber *hasOlderPages;
@property (nonatomic, strong, readwrite) NSSet *posts;
@property (nonatomic, strong, readwrite) NSSet *categories;
@property (nonatomic, strong, readwrite) NSSet *tags;
@property (nonatomic, strong, readwrite) NSSet *comments;
@property (nonatomic, strong, readwrite) NSSet *connections;
@property (nonatomic, strong, readwrite) NSSet *themes;
@property (nonatomic, strong, readwrite) NSSet *media;
@property (nonatomic, strong, readwrite) NSOrderedSet *menus;
@property (nonatomic, strong, readwrite) NSOrderedSet *menuLocations;
@property (nonatomic, strong, readwrite) NSString *currentThemeId;
@property (nonatomic, strong, readwrite, nullable) NSNumber *blogID __deprecated_msg("Use dotComID instead");
@property (nonatomic, strong, readwrite, nullable) NSNumber *dotComID;
@property (nonatomic, strong, readwrite, nullable) NSString *xmlrpc;
@property (nonatomic, strong, readwrite, nullable) NSString *apiKey;
@property (nonatomic, strong, readwrite, nullable) NSNumber *hasOlderPosts;
@property (nonatomic, strong, readwrite, nullable) NSNumber *hasOlderPages;
@property (nonatomic, strong, readwrite, nullable) NSSet *posts;
@property (nonatomic, strong, readwrite, nullable) NSSet *categories;
@property (nonatomic, strong, readwrite, nullable) NSSet *tags;
@property (nonatomic, strong, readwrite, nullable) NSSet *comments;
@property (nonatomic, strong, readwrite, nullable) NSSet *connections;
@property (nonatomic, strong, readwrite, nullable) NSSet *themes;
@property (nonatomic, strong, readwrite, nullable) NSSet *media;
@property (nonatomic, strong, readwrite, nullable) NSOrderedSet *menus;
@property (nonatomic, strong, readwrite, nullable) NSOrderedSet *menuLocations;
@property (nonatomic, strong, readwrite, nullable) NSString *currentThemeId;
@property (nonatomic, assign, readwrite) BOOL isSyncingPosts;
@property (nonatomic, assign, readwrite) BOOL isSyncingPages;
@property (nonatomic, assign, readwrite) BOOL isSyncingMedia;
@property (nonatomic, strong, readwrite) NSDate *lastPostsSync;
@property (nonatomic, strong, readwrite) NSDate *lastPagesSync;
@property (nonatomic, strong, readwrite) NSDate *lastCommentsSync;
@property (nonatomic, strong, readwrite) NSDate *lastStatsSync;
@property (nonatomic, strong, readwrite) NSString *lastUpdateWarning;
@property (nonatomic, strong, readwrite, nullable) NSDate *lastPostsSync;
@property (nonatomic, strong, readwrite, nullable) NSDate *lastPagesSync;
@property (nonatomic, strong, readwrite, nullable) NSDate *lastCommentsSync;
@property (nonatomic, strong, readwrite, nullable) NSDate *lastStatsSync;
@property (nonatomic, strong, readwrite, nullable) NSString *lastUpdateWarning;
@property (nonatomic, assign, readwrite) BOOL visible;
@property (nonatomic, weak, readwrite) NSNumber *isActivated;
@property (nonatomic, strong, readwrite) NSDictionary *options;
@property (nonatomic, strong, readwrite) NSSet *postTypes;
@property (nonatomic, strong, readwrite) NSDictionary *postFormats;
@property (nonatomic, strong, readwrite) WPAccount *account;
@property (nonatomic, strong, readwrite) WPAccount *jetpackAccount;
@property (nonatomic, strong, readwrite) WPAccount *accountForDefaultBlog;
@property (nonatomic, weak, readwrite, nullable) NSNumber *isActivated;
@property (nonatomic, strong, readwrite, nullable) NSDictionary *options;
@property (nonatomic, strong, readwrite, nullable) NSSet *postTypes;
@property (nonatomic, strong, readwrite, nullable) NSDictionary *postFormats;
@property (nonatomic, strong, readwrite, nullable) WPAccount *account;
@property (nonatomic, strong, readwrite, nullable) WPAccount *jetpackAccount;
@property (nonatomic, strong, readwrite, nullable) WPAccount *accountForDefaultBlog;
@property (nonatomic, assign, readwrite) BOOL videoPressEnabled;
@property (nonatomic, assign, readwrite) BOOL isMultiAuthor;
@property (nonatomic, assign, readwrite) BOOL isHostedAtWPcom;
@property (nonatomic, strong, readwrite) NSString *icon;
@property (nonatomic, strong, readwrite, nullable) NSString *icon;
@property (nonatomic, assign, readwrite) SiteVisibility siteVisibility;
@property (nonatomic, strong, readwrite) NSNumber *planID;
@property (nonatomic, strong, readwrite) NSSet *sharingButtons;
@property (nonatomic, strong, readwrite) NSDictionary *capabilities;
@property (nonatomic, strong, readwrite, nullable) NSNumber *planID;
@property (nonatomic, strong, readwrite, nullable) NSSet *sharingButtons;
@property (nonatomic, strong, readwrite, nullable) NSDictionary *capabilities;


/**
* @details Maps to a BlogSettings instance, which contains a collection of the available preferences,
* and their values.
*/
@property (nonatomic, strong, readwrite) BlogSettings *settings;
@property (nonatomic, strong, readwrite, nullable) BlogSettings *settings;

/**
* @details Flags whether the current user is an admin on the blog.
Expand All @@ -112,23 +114,23 @@ typedef NS_ENUM(NSInteger, SiteVisibility) {
*
* @warn For WordPress.com or Jetpack Managed sites this will be nil. Use usernameForSite instead
*/
@property (nonatomic, strong, readwrite) NSString *username;
@property (nonatomic, strong, readwrite) NSString *password;
@property (nonatomic, strong, readwrite, nullable) NSString *username;
@property (nonatomic, strong, readwrite, nullable) NSString *password;


// Readonly Properties
@property (nonatomic, weak, readonly) NSArray *sortedPostFormatNames;
@property (nonatomic, weak, readonly) NSArray *sortedPostFormats;
@property (nonatomic, strong, readonly) WPXMLRPCClient *api;
@property (nonatomic, weak, readonly) NSString *version;
@property (nonatomic, strong, readonly) NSString *authToken;
@property (nonatomic, strong, readonly) NSSet *allowedFileTypes;
@property (nonatomic, copy, readonly) NSString *usernameForSite;
@property (nonatomic, weak, readonly, nullable) NSArray *sortedPostFormatNames;
@property (nonatomic, weak, readonly, nullable) NSArray *sortedPostFormats;
@property (nonatomic, strong, readonly, nullable) WPXMLRPCClient *api;
@property (nonatomic, weak, readonly, nullable) NSString *version;
@property (nonatomic, strong, readonly, nullable) NSString *authToken;
@property (nonatomic, strong, readonly, nullable) NSSet *allowedFileTypes;
@property (nonatomic, copy, readonly, nullable) NSString *usernameForSite;

/**
* @details Contains the Jetpack state. Returns nil if the blog options haven't been downloaded yet
*/
@property (nonatomic, strong, readonly) JetpackState *jetpack;
@property (nonatomic, strong, readonly, nullable) JetpackState *jetpack;


/**
Expand All @@ -137,23 +139,23 @@ typedef NS_ENUM(NSInteger, SiteVisibility) {

// User to display the blog url to the user (IDN decoded, no http:)
// wp.koke.me/sub
@property (weak, readonly) NSString *displayURL;
@property (weak, readonly, nullable) NSString *displayURL;
// alias of displayURL
// kept for compatibilty, used as a key to store passwords
@property (weak, readonly) NSString *hostURL;
@property (weak, readonly) NSString *homeURL;
@property (weak, readonly, nullable) NSString *hostURL;
@property (weak, readonly, nullable) NSString *homeURL;
// http://wp.koke.me/sub
@property (nonatomic, strong) NSString *url;
@property (nonatomic, strong, nullable) NSString *url;
// Used for reachability checks (IDN encoded)
// wp.koke.me
@property (weak, readonly) NSString *hostname;
@property (weak, readonly, nullable) NSString *hostname;

@property (weak, readonly) NSString *defaultPostFormatText;
@property (weak, readonly, nullable) NSString *defaultPostFormatText;

#pragma mark - Blog information
- (BOOL)isPrivate;
- (NSArray *)sortedCategories;
- (id)getOptionValue:(NSString *) name;
- (nullable NSArray *)sortedCategories;
- (nullable id)getOptionValue:(NSString *) name;
- (NSString *)loginUrl;
- (NSString *)urlWithPath:(NSString *)path;
- (NSString *)adminUrlWithPath:(NSString *)path;
Expand All @@ -171,7 +173,7 @@ typedef NS_ENUM(NSInteger, SiteVisibility) {
*
* @return a string with the post format description and if no description was found the postFormatCode sent.
*/
- (NSString *)postFormatTextFromSlug:(NSString *)postFormatSlug;
- (nullable NSString *)postFormatTextFromSlug:(NSString *)postFormatSlug;
/**
Returns a human readable description for logging

Expand All @@ -190,6 +192,8 @@ typedef NS_ENUM(NSInteger, SiteVisibility) {

@return a WordPressComApi object if available
*/
- (WordPressComApi *)restApi;
- (nullable WordPressComApi *)restApi;

@end

NS_ASSUME_NONNULL_END
2 changes: 1 addition & 1 deletion WordPress/Classes/Services/PeopleService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct PeopleService {
}

remote = PeopleRemote(api: api)
siteID = blog.dotComID as Int
siteID = blog.dotComID as! Int
}


Expand Down
8 changes: 4 additions & 4 deletions WordPress/Classes/Services/SharingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class SharingService : LocalCoreDataService
guard let remote = remoteForBlog(blog) else {
return
}
remote.getPublicizeConnections(blog.dotComID, success: {(remoteConnections:[RemotePublicizeConnection]) in
remote.getPublicizeConnections(blog.dotComID!, success: {(remoteConnections:[RemotePublicizeConnection]) in

// Process the results
self.mergePublicizeConnectionsForBlog(blogObjectID, remoteConnections: remoteConnections, onComplete: success)
Expand Down Expand Up @@ -97,7 +97,7 @@ public class SharingService : LocalCoreDataService
guard let remote = remoteForBlog(blog) else {
return
}
let dotComID = blog.dotComID
let dotComID = blog.dotComID!
remote.createPublicizeConnection(dotComID,
keyringConnectionID: keyring.keyringID,
externalUserID: externalUserID,
Expand Down Expand Up @@ -546,7 +546,7 @@ public class SharingService : LocalCoreDataService
return
}

remote.getSharingButtonsForSite(blog.dotComID,
remote.getSharingButtonsForSite(blog.dotComID!,
success: { (remoteButtons:[RemoteSharingButton]) in
self.mergeSharingButtonsForBlog(blogObjectID, remoteSharingButtons: remoteButtons, onComplete: success)
},
Expand All @@ -570,7 +570,7 @@ public class SharingService : LocalCoreDataService
guard let remote = remoteForBlog(blog) else {
return
}
remote.updateSharingButtonsForSite(blog.dotComID,
remote.updateSharingButtonsForSite(blog.dotComID!,
sharingButtons: remoteShareButtonsFromShareButtons(sharingButtons),
success: { (remoteButtons:[RemoteSharingButton]) in
self.mergeSharingButtonsForBlog(blogObjectID, remoteSharingButtons: remoteButtons, onComplete: success)
Expand Down
6 changes: 3 additions & 3 deletions WordPress/Classes/Services/SiteManagementService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class SiteManagementService : LocalCoreDataService
guard let remote = siteManagementServiceRemoteForBlog(blog) else {
return
}
remote.deleteSite(blog.dotComID,
remote.deleteSite(blog.dotComID!,
success: {
self.managedObjectContext.performBlock {
let blogService = BlogService(managedObjectContext: self.managedObjectContext)
Expand Down Expand Up @@ -56,7 +56,7 @@ public class SiteManagementService : LocalCoreDataService
guard let remote = siteManagementServiceRemoteForBlog(blog) else {
return
}
remote.exportContent(blog.dotComID,
remote.exportContent(blog.dotComID!,
success: {
success?()
},
Expand All @@ -76,7 +76,7 @@ public class SiteManagementService : LocalCoreDataService
guard let remote = siteManagementServiceRemoteForBlog(blog) else {
return
}
remote.getActivePurchases(blog.dotComID,
remote.getActivePurchases(blog.dotComID!,
success: { purchases in
success?(purchases)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ public class DiscussionSettingsViewController : UITableViewController

// MARK: - Computed Properties
private var settings : BlogSettings {
return blog.settings
return blog.settings!
}

// MARK: - Typealiases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class LanguageViewController : UITableViewController

// MARK: - Private Methods
private func configureTableViewCell(cell: UITableViewCell) {
let languageId = blog.settings.languageID.integerValue
let languageId = blog.settings!.languageID.integerValue
cell.textLabel?.text = NSLocalizedString("Language", comment: "Language of the current blog")
cell.detailTextLabel?.text = languageDatabase.nameForLanguageWithId(languageId)
}
Expand All @@ -106,7 +106,7 @@ public class LanguageViewController : UITableViewController
// Setup ListPickerViewController
let listViewController = SettingsListPickerViewController(headers: headers, titles: titles, subtitles: subtitles, values: values)
listViewController.title = NSLocalizedString("Site Language", comment: "Title for the Language Picker View")
listViewController.selectedValue = blog.settings.languageID
listViewController.selectedValue = blog.settings!.languageID
listViewController.onChange = { [weak self] (selected: AnyObject) in
guard let newLanguageID = selected as? NSNumber else {
return
Expand Down
Loading