Skip to content

Commit 58a8a1e

Browse files
committed
v3.0.1034
1 parent 86d425b commit 58a8a1e

27 files changed

Lines changed: 256 additions & 229 deletions

iOS/WebDavCommon/AppGroupSettings.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,35 @@ public static class AppGroupSettings
1212
public static ServerSettings GetServerSettings()
1313
{
1414
using (NSUrl userDataPath = GetSharedContainerUrl())
15-
using (NSDictionary userData = NSDictionary.FromFile(Path.Combine(userDataPath.Path, ServerSettingFile)))
15+
using (var userData = NSDictionary.FromFile(Path.Combine(userDataPath.Path, ServerSettingFile)))
1616
{
17-
if (userData == null) return null;
17+
if (userData == null)
18+
{
19+
return null;
20+
}
21+
1822
return ServerSettings.CreateFromNsDictionary(userData);
1923
}
2024
}
2125

2226
private static NSUrl GetSharedContainerUrl()
2327
{
2428
NSUrl userDataPath = NSFileManager.DefaultManager.GetContainerUrl(AppGroupId);
25-
if (userDataPath == null) throw new AccessViolationException("Group container is null");
29+
if (userDataPath == null)
30+
{
31+
throw new AccessViolationException("Group container is null");
32+
}
33+
2634
return userDataPath;
2735
}
2836

2937
public static void SaveServerSettings(ServerSettings serverSettings)
3038
{
31-
if (serverSettings == null) throw new ArgumentNullException(nameof(serverSettings));
39+
if (serverSettings == null)
40+
{
41+
throw new ArgumentNullException(nameof(serverSettings));
42+
}
43+
3244
using (NSUrl userDataPath = GetSharedContainerUrl())
3345
using (NSDictionary data = serverSettings.ToNsDictionary())
3446
{

iOS/WebDavCommon/ServerSettings.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ public class ServerSettings
1212

1313
public ServerSettings(string serverUri, string userName = "", string password = "")
1414
{
15-
if(string.IsNullOrEmpty(serverUri)) throw new ArgumentException(serverUri);
15+
if(string.IsNullOrEmpty(serverUri))
16+
{
17+
throw new ArgumentException(serverUri);
18+
}
19+
1620
ServerUri = new Uri(serverUri);
1721
UserName = userName;
1822
Password = password;
@@ -22,7 +26,11 @@ public ServerSettings(string serverUri, string userName = "", string password =
2226

2327
public static ServerSettings CreateFromNsDictionary(NSDictionary userDataDictionary)
2428
{
25-
if(userDataDictionary == null) throw new ArgumentNullException(nameof(userDataDictionary));
29+
if(userDataDictionary == null)
30+
{
31+
throw new ArgumentNullException(nameof(userDataDictionary));
32+
}
33+
2634
NSObject serverUrl = userDataDictionary.ValueForKey((NSString) "ServerUri");
2735
NSObject userName = userDataDictionary.ValueForKey((NSString) "UserName");
2836
NSObject passWord = userDataDictionary.ValueForKey((NSString) "PassWord");

iOS/WebDavContainer/Info.plist

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>CFBundleDisplayName</key>
6-
<string>WebDAV Client</string>
6+
<string>IT Hit WebDAV Client</string>
77
<key>CFBundleExecutable</key>
88
<string>WebDavContainer</string>
99
<key>CFBundleIdentifier</key>
@@ -46,11 +46,10 @@
4646
<key>XSAppIconAssets</key>
4747
<string>Assets.xcassets/AppIcon.appiconset</string>
4848
<key>CFBundleVersion</key>
49-
<string>1032</string>
49+
<string>1034</string>
5050
<key>UIDeviceFamily</key>
5151
<array>
5252
<integer>1</integer>
53-
<integer>2</integer>
5453
</array>
5554
</dict>
5655
</plist>

iOS/WebDavContainer/Main.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
using UIKit;
2-
using System;
2+
33
namespace WebDavContainer
44
{
55
public class Application
66
{
77
// This is the main entry point of the application.
88
static void Main(string[] args)
99
{
10-
try
11-
{
12-
// if you want to use a different Application Delegate class from "AppDelegate"
13-
// you can specify it here.
14-
UIApplication.Main(args, null, "AppDelegate");
15-
}
16-
catch(Exception x)
17-
{
18-
19-
}
10+
// if you want to use a different Application Delegate class from "AppDelegate"
11+
// you can specify it here.
12+
UIApplication.Main(args, null, "AppDelegate");
2013
}
2114
}
22-
}
15+
}

iOS/WebDavContainer/ViewController.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public override void ViewDidLoad()
1818
ServerSettings serverSettings = AppGroupSettings.GetServerSettings();
1919
if(serverSettings != null)
2020
{
21-
Server.Text = serverSettings.ServerUri.ToString() ?? string.Empty;
21+
Server.Text = serverSettings.ServerUri.ToString();
2222
Username.Text = serverSettings.UserName ?? string.Empty;
2323
Password.Text = serverSettings.Password ?? string.Empty;
2424
}
@@ -28,20 +28,14 @@ public override void ViewDidLoad()
2828
#endif
2929
}
3030

31-
public override void DidReceiveMemoryWarning()
32-
{
33-
base.DidReceiveMemoryWarning();
34-
// Release any cached data, images, etc that aren't in use.
35-
}
36-
3731
partial void Login_Clicked(UIButton sender)
3832
{
3933
string serverUri = Server.Text;
4034
string userName = Username.Text;
4135
string passWord = Password.Text;
4236

4337

44-
if(String.IsNullOrEmpty(serverUri) || String.IsNullOrWhiteSpace(serverUri))
38+
if(string.IsNullOrEmpty(serverUri) || string.IsNullOrWhiteSpace(serverUri))
4539
{
4640
UIAlertView alert = new UIAlertView()
4741
{
@@ -57,21 +51,23 @@ partial void Login_Clicked(UIButton sender)
5751
{
5852
var serverSettings = new ServerSettings(serverUri, userName, passWord);
5953
AppGroupSettings.SaveServerSettings(serverSettings);
60-
UIAlertView alert = new UIAlertView()
54+
var alert = new UIAlertView()
6155
{
6256
Title = "Login successful",
63-
Message = "Now you can open documents in MS Office or any other application from http://server/ via Location->Browse dialog and save back directly to server."
57+
Message = "Now you can open documents from your server in MS Office Mobile or any other application via Location->Browse dialog and save back directly to server."
6458
};
59+
6560
alert.AddButton("Ok");
6661
alert.Show();
6762
}
6863
catch(Exception ex)
6964
{
70-
UIAlertView doneAlert = new UIAlertView()
65+
var doneAlert = new UIAlertView()
7166
{
7267
Title = "Error",
7368
Message = ex.Message
7469
};
70+
7571
doneAlert.AddButton("Ok");
7672
doneAlert.Show();
7773
}

iOS/WebDavContainerExtension/Extension.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.IO;
44
using System.Net;
55
using System.Runtime.InteropServices;
6-
using FileProvider;
76
using Foundation;
87
using MobileCoreServices;
98
using ObjCRuntime;
@@ -17,14 +16,14 @@ namespace WebDavContainerExtension
1716
public static class Extension
1817
{
1918
[DllImport(Constants.MobileCoreServicesLibrary, EntryPoint = "UTTypeCreatePreferredIdentifierForTag")]
20-
public static extern IntPtr UTTypeCreatePreferredIdentifierForTag(IntPtr tagClass, IntPtr tag, IntPtr uti);
19+
private static extern IntPtr UTTypeCreatePreferredIdentifierForTag(IntPtr tagClass, IntPtr tag, IntPtr uti);
2120

2221

2322
public static string GetUTType(string fileExtension)
2423
{
2524
fileExtension = fileExtension.Substring(1);
2625
NSString classRef = new NSString(UTType.TagClassFilenameExtension);
27-
NSString mimeRef = new NSString(fileExtension);
26+
var mimeRef = new NSString(fileExtension);
2827

2928
IntPtr utiRef = UTTypeCreatePreferredIdentifierForTag(classRef.Handle, mimeRef.Handle, IntPtr.Zero);
3029

@@ -36,7 +35,7 @@ public static string GetUTType(string fileExtension)
3635
public static string Decode(string source)
3736
{
3837
string[] sourceElements = source.Split('/');
39-
List<string> resultElements = new List<string>();
38+
var resultElements = new List<string>();
4039
foreach(string element in sourceElements)
4140
{
4241
resultElements.Add(WebUtility.UrlDecode(element));
@@ -50,7 +49,7 @@ public static string Decode(string source)
5049
public static string Encode(string source)
5150
{
5251
string[] sourceElements = source.Split('/');
53-
List<string> resultElements = new List<string>();
52+
var resultElements = new List<string>();
5453
foreach(string element in sourceElements)
5554
{
5655
resultElements.Add(WebUtility.UrlEncode(element));
@@ -72,7 +71,6 @@ public static string GetTypeIdentifier(string type, string itemName)
7271
baseType += ".folder";
7372
break;
7473
}
75-
;
7674
default:
7775
{
7876
string fileExtension = Path.GetExtension(itemName);

iOS/WebDavContainerExtension/Extensions/NSErrorExtension.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ public static class NSErrorExtension
77
{
88
public static NSErrorException AsException(this NSError error)
99
{
10-
if(error == null) throw new ArgumentNullException(nameof(error));
10+
if(error == null)
11+
{
12+
throw new ArgumentNullException(nameof(error));
13+
}
14+
1115
return new NSErrorException(error);
1216
}
1317
}

iOS/WebDavContainerExtension/FileProviderEnumerators/EmptyEnumerator.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using FileProvider;
1+
using FileProvider;
32
using Foundation;
43

54
namespace WebDavContainerExtension.FileProviderEnumerators

iOS/WebDavContainerExtension/FileProviderEnumerators/FileEnumerator.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Linq;
32
using FileProvider;
43
using Foundation;
54
using ITHit.WebDAV.Client.Exceptions;
@@ -45,15 +44,15 @@ public void EnumerateItems(INSFileProviderEnumerationObserver observer, NSData s
4544
observer.DidEnumerateItems(new[] {item});
4645
observer.FinishEnumerating((NSData) null);
4746
}
48-
catch(UnauthorizedException ex)
47+
catch(UnauthorizedException)
4948
{
5049
observer.FinishEnumerating(NsErrorHelper.GetFileProviderNotFoundError(this.EnumeratedItemIdentifier));
5150
}
52-
catch(WebDavHttpException ex)
51+
catch(WebDavHttpException)
5352
{
5453
observer.FinishEnumerating(NsErrorHelper.GetUnspecifiedServerError());
5554
}
56-
catch(Exception ex)
55+
catch(Exception)
5756
{
5857
observer.FinishEnumerating(NsErrorHelper.GetUnspecifiedErrorError());
5958
}
@@ -75,15 +74,15 @@ public void EnumerateChanges(INSFileProviderChangeObserver observer, NSData sync
7574
observer.DidUpdateItems(new[] { ProviderItem.CreateFromMetadata(metadata) });
7675
observer.FinishEnumeratingChanges(this.GetNsDataFromUint(this.SyncAnchor++), false);
7776
}
78-
catch(UnauthorizedException ex)
77+
catch(UnauthorizedException)
7978
{
8079
observer.FinishEnumerating(NsErrorHelper.GetFileProviderUnauthorizedError());
8180
}
82-
catch(WebDavHttpException ex)
81+
catch(WebDavHttpException)
8382
{
8483
observer.FinishEnumerating(NsErrorHelper.GetUnspecifiedServerError());
8584
}
86-
catch(Exception ex)
85+
catch(Exception)
8786
{
8887
observer.FinishEnumerating(NsErrorHelper.GetUnspecifiedErrorError());
8988
}

iOS/WebDavContainerExtension/FileProviderEnumerators/FolderEnumerator.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ public void EnumerateItems(INSFileProviderEnumerationObserver observer, NSData s
4949
observer.DidEnumerateItems(items);
5050
observer.FinishEnumerating((NSData) null);
5151
}
52-
catch (UnauthorizedException ex)
52+
catch (UnauthorizedException)
5353
{
5454
observer.FinishEnumerating(NsErrorHelper.GetFileProviderUnauthorizedError());
5555
}
56-
catch (WebDavHttpException ex)
56+
catch (WebDavHttpException)
5757
{
5858
observer.FinishEnumerating(NsErrorHelper.GetUnspecifiedServerError());
5959
}
60-
catch (Exception ex)
60+
catch (Exception)
6161
{
6262
observer.FinishEnumerating(NsErrorHelper.GetUnspecifiedErrorError());
6363
}
@@ -86,15 +86,15 @@ public void EnumerateChanges(INSFileProviderChangeObserver observer, NSData sync
8686
this.SyncAnchor = this.changeTracker.AddChangeSet(metadatas);
8787
observer.FinishEnumeratingChanges(this.GetCurrentAnchorNsData(this.SyncAnchor), false);
8888
}
89-
catch (UnauthorizedException ex)
89+
catch (UnauthorizedException)
9090
{
9191
observer.FinishEnumerating(NsErrorHelper.GetFileProviderUnauthorizedError());
9292
}
93-
catch (WebDavHttpException ex)
93+
catch (WebDavHttpException)
9494
{
9595
observer.FinishEnumerating(NsErrorHelper.GetUnspecifiedServerError());
9696
}
97-
catch (Exception ex)
97+
catch (Exception)
9898
{
9999
observer.FinishEnumerating(NsErrorHelper.GetUnspecifiedErrorError());
100100
}

0 commit comments

Comments
 (0)