filtered = list.ToList();
46 | Messages = filtered;
47 | }
48 |
49 | public int Unread { get; set; }
50 | public Constants.MMBType Type { get; set; }
51 | }
52 | }
--------------------------------------------------------------------------------
/iOS/FlyoutController.designer.cs:
--------------------------------------------------------------------------------
1 | // WARNING
2 | //
3 | // This file has been generated automatically by Xamarin Studio to store outlets and
4 | // actions made in the UI designer. If it is removed, they will be lost.
5 | // Manual changes to this file may not be handled correctly.
6 | //
7 | using MonoTouch.Foundation;
8 | using System.CodeDom.Compiler;
9 |
10 | namespace AltinnApp.iOS
11 | {
12 | [Register ("FlyoutController")]
13 | partial class FlyoutController
14 | {
15 | [Outlet]
16 | MonoTouch.UIKit.UIImageView _actorForwardIcon { get; set; }
17 |
18 | [Outlet]
19 | MonoTouch.UIKit.UIButton _actorLabel { get; set; }
20 |
21 | [Outlet]
22 | MonoTouch.UIKit.UILabel _lastNameLabel { get; set; }
23 |
24 | [Outlet]
25 | MonoTouch.UIKit.UIButton _logoutButton { get; set; }
26 |
27 | [Outlet]
28 | MonoTouch.UIKit.UIImageView _nameIcon { get; set; }
29 |
30 | [Outlet]
31 | MonoTouch.UIKit.UILabel _nameLabel { get; set; }
32 |
33 | [Outlet]
34 | MonoTouch.UIKit.UITableView _tableView { get; set; }
35 |
36 | [Action ("_logout:")]
37 | partial void _logout (MonoTouch.Foundation.NSObject sender);
38 |
39 | void ReleaseDesignerOutlets ()
40 | {
41 | if (_actorForwardIcon != null) {
42 | _actorForwardIcon.Dispose ();
43 | _actorForwardIcon = null;
44 | }
45 |
46 | if (_actorLabel != null) {
47 | _actorLabel.Dispose ();
48 | _actorLabel = null;
49 | }
50 |
51 | if (_lastNameLabel != null) {
52 | _lastNameLabel.Dispose ();
53 | _lastNameLabel = null;
54 | }
55 |
56 | if (_logoutButton != null) {
57 | _logoutButton.Dispose ();
58 | _logoutButton = null;
59 | }
60 |
61 | if (_nameIcon != null) {
62 | _nameIcon.Dispose ();
63 | _nameIcon = null;
64 | }
65 |
66 | if (_nameLabel != null) {
67 | _nameLabel.Dispose ();
68 | _nameLabel = null;
69 | }
70 |
71 | if (_tableView != null) {
72 | _tableView.Dispose ();
73 | _tableView = null;
74 | }
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/iOS/Components/btprogresshud-1.9/samples/BTProgressHUDSample/BTProgressHUDSample.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTProgressHUDDemo", "BTProgressHUDSample\BTProgressHUDDemo.csproj", "{E6E84D09-BE15-460D-A317-45248BE1C56F}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|iPhoneSimulator = Debug|iPhoneSimulator
9 | Release|iPhoneSimulator = Release|iPhoneSimulator
10 | Debug|iPhone = Debug|iPhone
11 | Release|iPhone = Release|iPhone
12 | Ad-Hoc|iPhone = Ad-Hoc|iPhone
13 | AppStore|iPhone = AppStore|iPhone
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {E6E84D09-BE15-460D-A317-45248BE1C56F}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
17 | {E6E84D09-BE15-460D-A317-45248BE1C56F}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
18 | {E6E84D09-BE15-460D-A317-45248BE1C56F}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
19 | {E6E84D09-BE15-460D-A317-45248BE1C56F}.AppStore|iPhone.Build.0 = AppStore|iPhone
20 | {E6E84D09-BE15-460D-A317-45248BE1C56F}.Debug|iPhone.ActiveCfg = Debug|iPhone
21 | {E6E84D09-BE15-460D-A317-45248BE1C56F}.Debug|iPhone.Build.0 = Debug|iPhone
22 | {E6E84D09-BE15-460D-A317-45248BE1C56F}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
23 | {E6E84D09-BE15-460D-A317-45248BE1C56F}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
24 | {E6E84D09-BE15-460D-A317-45248BE1C56F}.Release|iPhone.ActiveCfg = Release|iPhone
25 | {E6E84D09-BE15-460D-A317-45248BE1C56F}.Release|iPhone.Build.0 = Release|iPhone
26 | {E6E84D09-BE15-460D-A317-45248BE1C56F}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
27 | {E6E84D09-BE15-460D-A317-45248BE1C56F}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
28 | EndGlobalSection
29 | GlobalSection(MonoDevelopProperties) = preSolution
30 | StartupItem = BTProgressHUDSample\BTProgressHUDDemo.csproj
31 | EndGlobalSection
32 | EndGlobal
33 |
--------------------------------------------------------------------------------
/iOS/Components/btprogresshud-1.9/component/License.md:
--------------------------------------------------------------------------------
1 | Copyright 2013 Nic Wise / Big Ted Ltd and Sam Vermette
2 |
3 | BTProgressHUD:
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | SVProgressHUD:
18 |
19 | Copyright (c) 2011 Sam Vermette
20 |
21 | Permission is hereby granted, free of charge, to any person
22 | obtaining a copy of this software and associated documentation
23 | files (the "Software"), to deal in the Software without
24 | restriction, including without limitation the rights to use,
25 | copy, modify, merge, publish, distribute, sublicense, and/or sell
26 | copies of the Software, and to permit persons to whom the
27 | Software is furnished to do so, subject to the following
28 | conditions:
29 |
30 | The above copyright notice and this permission notice shall be
31 | included in all copies or substantial portions of the Software.
32 |
33 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
34 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
35 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
36 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
37 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
38 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
39 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
40 | OTHER DEALINGS IN THE SOFTWARE.
41 |
42 | A different license may apply to other ressources included in this package,
43 | including Joseph Wain's Glyphish Icons. Please consult their
44 | respective headers for the terms of their individual licenses.
45 |
--------------------------------------------------------------------------------
/iOS/FlyoutTablesource.cs:
--------------------------------------------------------------------------------
1 | using MonoTouch.Foundation;
2 | using MonoTouch.UIKit;
3 |
4 | namespace AltinnApp.iOS
5 | {
6 | public class FlyoutTablesource : UITableViewSource
7 | {
8 | private readonly CorePlatform.Translate _trans;
9 |
10 | public FlyoutTablesource()
11 | {
12 | _trans = new CorePlatform.Translate();
13 | }
14 |
15 |
16 | public override int RowsInSection(UITableView tableview, int section)
17 | {
18 | return 5;
19 | }
20 |
21 |
22 | public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
23 | {
24 | string cellIdentifier = "Cell";
25 | string cellLabel = string.Empty;
26 |
27 |
28 | switch (indexPath.Row)
29 | {
30 | case 0:
31 |
32 | cellIdentifier = "Inbox";
33 | cellLabel = _trans.GetString("MessageboxController_InboxHeader");
34 | break;
35 |
36 | case 1:
37 | cellIdentifier = "Archive";
38 | cellLabel = _trans.GetString("MessageboxController_ArchiveHeader");
39 | break;
40 | case 2:
41 | cellIdentifier = "Settings";
42 | cellLabel = _trans.GetString("SettingsController_Header");
43 | break;
44 | case 3:
45 | cellIdentifier = "Contact";
46 | cellLabel = _trans.GetString("ContactController_Header");
47 | break;
48 | case 4:
49 | cellIdentifier = "Feedback";
50 | cellLabel = _trans.GetString("FeedbackController_Header");
51 | break;
52 | }
53 |
54 | UITableViewCell cell = tableView.DequeueReusableCell(cellIdentifier);
55 | var selectedBackgroundView = new UIView(cell.Frame) { BackgroundColor = UIColor.FromRGB(73, 73, 73) };
56 | cell.SelectedBackgroundView = selectedBackgroundView;
57 |
58 | cell.BackgroundColor = UIColor.FromRGB (108, 108, 108);
59 | var backgroundView = new UIView(cell.Frame) { BackgroundColor = UIColor.FromRGB(108, 108, 108) };
60 | cell.BackgroundView = backgroundView;
61 |
62 |
63 | cell.ContentView.BackgroundColor = UIColor.FromRGB(108, 108, 108);
64 |
65 |
66 | cell.TextLabel.Text = cellLabel;
67 |
68 | return cell;
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/Core/Util/Util.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace AltinnApp.Core.Util
5 | {
6 | public static class Util
7 | {
8 | public static bool IsHtml(string summary)
9 | {
10 | if (summary.Contains("") || summary.Contains("") || summary.Contains("
") ||
11 | summary.Contains("
") || summary.Contains(""))
12 | {
13 | return true;
14 | }
15 | return false;
16 | }
17 |
18 | ///
19 | /// Parses a 401 "insufficient authentication level exception for the levels needed
20 | ///
21 | /// The exception message from the API
22 | /// Dictionary with the requred and current security level
23 | public static Dictionary GetAutLevel(string message)
24 | {
25 | //If we get the "Not authorized" message it will look like this: This operation requires authentication level 2 Current level is only 1
26 | var ints = new List();
27 |
28 | // ReSharper disable once LoopCanBeConvertedToQuery
29 | foreach (char c in message)
30 | {
31 | if (Char.IsDigit(c))
32 | {
33 | ints.Add(c);
34 | }
35 | }
36 |
37 | var dic = new Dictionary();
38 | if (ints.Count > 0)
39 | {
40 | //We know the first one is the "required" and the second one is what we currently have
41 | dic.Add("required", ints[0]);
42 | dic.Add("current", ints[1]);
43 | }
44 |
45 | return dic;
46 | }
47 |
48 | ///
49 | /// Convenience method to add headers
50 | ///
51 | ///
52 | ///
53 | ///
54 | ///
55 | public static Dictionary AddHeader(string key, string value, Dictionary headers)
56 | {
57 | if (headers == null)
58 | {
59 | headers = new Dictionary();
60 | }
61 |
62 | if (!headers.ContainsKey(key))
63 | {
64 | headers.Add(key, value);
65 | }
66 |
67 | return headers;
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/Core/Models/Session.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace AltinnApp.Core.Models
5 | {
6 | ///
7 | /// The Seesion the current user has
8 | ///
9 | public static class Session
10 | {
11 | public static object SentCorres = "Arkivert";
12 |
13 | public static object Sent = "Sendt og arkivert";
14 |
15 | public static List Organizations { get; set; }
16 |
17 | public static List UnfilteredOrganizations { get; set; }
18 |
19 | public static Organization SelectedOrg { get; set; }
20 |
21 | public static Messagebox mmb { get; set; }
22 |
23 | public static Messagebox mab { get; set; }
24 |
25 | public static void SearchActor(string searchText)
26 | {
27 | List mess = UnfilteredOrganizations;
28 | var list =
29 | mess.Where(
30 | m =>
31 | m.Name.ToLower().Contains(searchText.ToLower()) ||
32 | m.OrganizationNumber.ToLower().Contains(searchText.ToLower()));
33 | List filtered = list.ToList();
34 | Organizations = filtered;
35 | }
36 |
37 | public static void Logout()
38 | {
39 | //When the user logs out, clear the cookies
40 | //Session.AuthCookie = null;
41 | CookieJar = new CookieJar();
42 | IDPortenCookie = null;
43 | LoggedIn = false;
44 | SelectedOrg = null;
45 | Organizations = null;
46 | Profile = null;
47 | UnfilteredOrganizations = null;
48 | mmb = null;
49 | }
50 |
51 | ///
52 | /// Gets or sets the container for our cookies
53 | ///
54 | public static CookieJar CookieJar { get; set; }
55 |
56 | ///
57 | /// Gets or sets the IDPorten cookie explicitly needed to open SvarUT Correspondences
58 | ///
59 | public static Cookie IDPortenCookie { get; set; }
60 |
61 | ///
62 | /// Gets or sets a value indicating whether this user is logged in
63 | ///
64 | public static bool LoggedIn { get; set; }
65 |
66 | ///
67 | /// Gets or sets a value indicating whether the app tried to log out using external Safari
68 | ///
69 | public static bool DidLogOut { get; set; }
70 |
71 | public static Profile Profile { get; set; }
72 | }
73 | }
--------------------------------------------------------------------------------
/iOS/InfoscreenController.designer.cs:
--------------------------------------------------------------------------------
1 | // WARNING
2 | //
3 | // This file has been generated automatically by Xamarin Studio to store outlets and
4 | // actions made in the UI designer. If it is removed, they will be lost.
5 | // Manual changes to this file may not be handled correctly.
6 | //
7 | using MonoTouch.Foundation;
8 | using System.CodeDom.Compiler;
9 |
10 | namespace AltinnApp.iOS
11 | {
12 | [Register ("InfoscreenController")]
13 | partial class InfoscreenController
14 | {
15 | [Outlet]
16 | MonoTouch.UIKit.UILabel _body1 { get; set; }
17 |
18 | [Outlet]
19 | MonoTouch.UIKit.UILabel _body2 { get; set; }
20 |
21 | [Outlet]
22 | MonoTouch.UIKit.UILabel _body3 { get; set; }
23 |
24 | [Outlet]
25 | MonoTouch.UIKit.UILabel _body4 { get; set; }
26 |
27 | [Outlet]
28 | MonoTouch.UIKit.UILabel _body5 { get; set; }
29 |
30 | [Outlet]
31 | MonoTouch.UIKit.UIButton _cancel { get; set; }
32 |
33 | [Outlet]
34 | MonoTouch.UIKit.UIButton _continue { get; set; }
35 |
36 | [Outlet]
37 | MonoTouch.UIKit.UILabel _headerBottom { get; set; }
38 |
39 | [Outlet]
40 | MonoTouch.UIKit.UILabel _headerTop { get; set; }
41 |
42 | [Outlet]
43 | MonoTouch.UIKit.UILabel _intro { get; set; }
44 |
45 | [Outlet]
46 | MonoTouch.UIKit.UILabel _outtro { get; set; }
47 |
48 | [Action ("Cancel:")]
49 | partial void Cancel (MonoTouch.Foundation.NSObject sender);
50 |
51 | [Action ("Continue:")]
52 | partial void Continue (MonoTouch.Foundation.NSObject sender);
53 |
54 | void ReleaseDesignerOutlets ()
55 | {
56 | if (_cancel != null) {
57 | _cancel.Dispose ();
58 | _cancel = null;
59 | }
60 |
61 | if (_continue != null) {
62 | _continue.Dispose ();
63 | _continue = null;
64 | }
65 |
66 | if (_intro != null) {
67 | _intro.Dispose ();
68 | _intro = null;
69 | }
70 |
71 | if (_headerTop != null) {
72 | _headerTop.Dispose ();
73 | _headerTop = null;
74 | }
75 |
76 | if (_body1 != null) {
77 | _body1.Dispose ();
78 | _body1 = null;
79 | }
80 |
81 | if (_body2 != null) {
82 | _body2.Dispose ();
83 | _body2 = null;
84 | }
85 |
86 | if (_body3 != null) {
87 | _body3.Dispose ();
88 | _body3 = null;
89 | }
90 |
91 | if (_headerBottom != null) {
92 | _headerBottom.Dispose ();
93 | _headerBottom = null;
94 | }
95 |
96 | if (_body4 != null) {
97 | _body4.Dispose ();
98 | _body4 = null;
99 | }
100 |
101 | if (_body5 != null) {
102 | _body5.Dispose ();
103 | _body5 = null;
104 | }
105 |
106 | if (_outtro != null) {
107 | _outtro.Dispose ();
108 | _outtro = null;
109 | }
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/iOS/InfoscreenController.cs:
--------------------------------------------------------------------------------
1 | // This file has been autogenerated from a class added in the UI designer.
2 |
3 | using System;
4 | using MonoTouch.Foundation;
5 | using MonoTouch.UIKit;
6 | using AltinnApp.Core.Models;
7 |
8 | namespace AltinnApp.iOS
9 | {
10 | public partial class InfoscreenController : UIViewController
11 | {
12 | private CorePlatform.Translate _trans;
13 |
14 | public InfoscreenController(IntPtr handle)
15 | : base(handle)
16 | {
17 | }
18 |
19 | private void Localize()
20 | {
21 | _intro.Text = _trans.GetString("InfoscreenController_Intro");
22 | _headerTop.Text = _trans.GetString("InfoscreenController_HeaderTop");
23 | _body1.Text = _trans.GetString("InfoscreenController_Body1");
24 | _body2.Text = _trans.GetString("InfoscreenController_Body2");
25 | _body3.Text = _trans.GetString("InfoscreenController_Body3");
26 | _body4.Text = _trans.GetString("InfoscreenController_Body4");
27 | _headerBottom.Text = _trans.GetString("InfoscreenController_HeaderBottom");
28 | _body5.Text = _trans.GetString("InfoscreenController_Body5");
29 | //_outtro.Text = _trans.GetString("InfoscreenController_Bottom");
30 |
31 | _cancel.SetTitle(_trans.GetString("Misc_Cancel"), UIControlState.Normal);
32 | _continue.SetTitle(_trans.GetString("InfoscreenController_Continue"), UIControlState.Normal);
33 | }
34 |
35 | public override void ViewDidLoad()
36 | {
37 | _trans = new CorePlatform.Translate();
38 | Localize();
39 | }
40 |
41 | // ReSharper disable once UnusedMember.Local
42 | // ReSharper disable once UnusedParameter.Local
43 | partial void Cancel(NSObject sender)
44 | {
45 | DismissViewController(true, null);
46 | }
47 |
48 | // ReSharper disable once UnusedMember.Local
49 | // ReSharper disable once UnusedParameter.Local
50 | partial void Continue(NSObject sender)
51 | {
52 | NSUserDefaults.StandardUserDefaults.SetBool(true, "hasLaunched");
53 | //For the environments with the new BankID solution we use the new BankID solution
54 | //which is to use AppStart.aspx as a proxy for the login, we need to send along this app's URL schema and the APIKey
55 | var url =
56 | new NSUrl(AppContext.AppStartUrl + "?ApiDomain=" + AppContext.AppUrlSchema + "&ApiKey=" +
57 | AppContext.ApiKey);
58 | UIApplication.SharedApplication.OpenUrl(url);
59 | AppContext.LoginMethod = 2; //External browser method
60 | DismissViewController(true, null);
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/iOS/ContactController.designer.cs:
--------------------------------------------------------------------------------
1 | // WARNING
2 | //
3 | // This file has been generated automatically by Xamarin Studio to store outlets and
4 | // actions made in the UI designer. If it is removed, they will be lost.
5 | // Manual changes to this file may not be handled correctly.
6 | //
7 | using MonoTouch.Foundation;
8 | using System.CodeDom.Compiler;
9 |
10 | namespace AltinnApp.iOS
11 | {
12 | [Register ("ContactController")]
13 | partial class ContactController
14 | {
15 | [Outlet]
16 | MonoTouch.UIKit.UILabel _bodyBottom { get; set; }
17 |
18 | [Outlet]
19 | MonoTouch.UIKit.UILabel _bodyBottomHeader { get; set; }
20 |
21 | [Outlet]
22 | MonoTouch.UIKit.UILabel _bodyTop { get; set; }
23 |
24 | [Outlet]
25 | MonoTouch.UIKit.UILabel _bodyTopHeader { get; set; }
26 |
27 | [Outlet]
28 | MonoTouch.UIKit.UIButton _contactMail { get; set; }
29 |
30 | [Outlet]
31 | MonoTouch.UIKit.UIButton _contactTlf { get; set; }
32 |
33 | [Outlet]
34 | MonoTouch.UIKit.UIButton _facebookButton { get; set; }
35 |
36 | [Outlet]
37 | MonoTouch.UIKit.UIButton _gobackButton { get; set; }
38 |
39 | [Outlet]
40 | MonoTouch.UIKit.UILabel _header { get; set; }
41 |
42 | [Outlet]
43 | MonoTouch.UIKit.UIButton _twitterButton { get; set; }
44 |
45 | [Action ("Call:")]
46 | partial void Call (MonoTouch.Foundation.NSObject sender);
47 |
48 | [Action ("OpenFacebook:")]
49 | partial void OpenFacebook (MonoTouch.Foundation.NSObject sender);
50 |
51 | [Action ("OpenTwitter:")]
52 | partial void OpenTwitter (MonoTouch.Foundation.NSObject sender);
53 |
54 | [Action ("SendMail:")]
55 | partial void SendMail (MonoTouch.Foundation.NSObject sender);
56 |
57 | void ReleaseDesignerOutlets ()
58 | {
59 | if (_bodyBottom != null) {
60 | _bodyBottom.Dispose ();
61 | _bodyBottom = null;
62 | }
63 |
64 | if (_bodyBottomHeader != null) {
65 | _bodyBottomHeader.Dispose ();
66 | _bodyBottomHeader = null;
67 | }
68 |
69 | if (_bodyTop != null) {
70 | _bodyTop.Dispose ();
71 | _bodyTop = null;
72 | }
73 |
74 | if (_bodyTopHeader != null) {
75 | _bodyTopHeader.Dispose ();
76 | _bodyTopHeader = null;
77 | }
78 |
79 | if (_contactMail != null) {
80 | _contactMail.Dispose ();
81 | _contactMail = null;
82 | }
83 |
84 | if (_contactTlf != null) {
85 | _contactTlf.Dispose ();
86 | _contactTlf = null;
87 | }
88 |
89 | if (_facebookButton != null) {
90 | _facebookButton.Dispose ();
91 | _facebookButton = null;
92 | }
93 |
94 | if (_gobackButton != null) {
95 | _gobackButton.Dispose ();
96 | _gobackButton = null;
97 | }
98 |
99 | if (_header != null) {
100 | _header.Dispose ();
101 | _header = null;
102 | }
103 |
104 | if (_twitterButton != null) {
105 | _twitterButton.Dispose ();
106 | _twitterButton = null;
107 | }
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/iOS/Components/btprogresshud-1.9/component/GettingStarted.md:
--------------------------------------------------------------------------------
1 | #Usage
2 |
3 | Have a look at the BTProgressHUDDemo project.
4 |
5 | Firstly, you need to use the BigTed namespace
6 |
7 | ```csharp
8 | using BigTed;
9 | ```
10 |
11 | Then, there are a few main static methods for showing the HUD:
12 |
13 | ```csharp
14 | BTProgressHUD.Show(); //shows the spinner
15 | BTProgressHUD.Show("Oh hai"); //show spinner + text
16 | BTProgressHUD.ShowSuccessWithStatus("Wow, that worked"); //A big TICK with text
17 | BTProgressHUD.ShowErrorWithStatus("Fail!"); //A big CROSS with text
18 | BTProgressHUD.ShowToast("Hello from Toast"); //show an Android-style toast
19 | ```
20 | All of these can be dismissed, once your processing is finished, with
21 |
22 | ```csharp
23 | BTProgressHUD.Dismiss();
24 | ```
25 |
26 | ShowToast, ShowSuccessWithStatus, ShowErrorWithStatus, and ShowImage all auto-dismiss.
27 |
28 | BTProgressHUD is aware of the thread you are calling from, and ensures that HUDs are always manipulated from the UI thread.
29 |
30 | #Using on iOS6
31 |
32 | If your app needs to work against the iOS6 SDK, but with the user on iOS7, you can set
33 |
34 | ```csharp
35 | BTProgressHUD.ForceiOS6LookAndFeel = true;
36 | ```
37 |
38 | And all the dialog boxes will look like iOS6 (black with white text, not the other way)
39 |
40 | #Other Show options
41 |
42 | You can call Show with the following parameters
43 |
44 | * status: - show status text
45 | * progress: - show a progress circle with 0.0 - 1.0 of progress. Call again to change the progress.
46 | * maskType: - show with the background (the whole window) clear, black or gradient. Default is none, which allows interaction with the underlying elements.
47 |
48 | ```csharp
49 | public enum MaskType
50 | {
51 | None = 1, // allow user interactions, don't dim background UI (default)
52 | Clear, // disable user interactions, don't dim background UI
53 | Black, // disable user interactions, dim background UI with 50% translucent black
54 | Gradient // disable user interactions, dim background UI with translucent radial gradient (a-la-alertView)
55 | }
56 | ```
57 |
58 | #ShowToast
59 | The toast can be centered or at the bottom of the screen, like Android. This is controlled by the second parameter.
60 |
61 | ```csharp
62 | BTProgressHUD.ShowToast ("Your download finished", showToastCentered: false);
63 | ```
64 |
65 | #ShowSuccess/Error/ShowImage
66 | This method dismisses the activity after 1 second. You can provide your own images if needed - make them 28x28 white PNGs.
67 |
68 | ```csharp
69 | BTProgressHUD.ShowSuccessWithStatus ("Wow, that worked"); //A big TICK with text
70 | BTProgressHUD.ShowErrorWithStatus ("Fail!"); //A big CROSS with text
71 | BTProgressHUD.ShowImage (UIImage.FromFile("an-image-file.png"), "Nice one Stu!");
72 | ```
73 |
74 | You can use the timeout parameter of ShowImage to control the time before it's dismissed.
75 |
76 | # Other Resources
77 |
78 | * [Source code](https://github.com/nicwise/BTProgressHUD/)
79 |
--------------------------------------------------------------------------------
/iOS/Properties/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
22 |
23 |
24 |
25 |
26 |
28 |
29 |
30 |
31 |
32 |
33 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
56 |
--------------------------------------------------------------------------------
/iOS/Components/btprogresshud-1.9/samples/BTProgressHUDSample/BTProgressHUDSample/MainView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MonoTouch.UIKit;
3 | using BigTed;
4 | using System.Threading;
5 | using System.Drawing;
6 | using System.Collections.Generic;
7 | using MonoTouch.Foundation;
8 |
9 |
10 | /*
11 | * The source for this is on
12 | * https://github.com/nicwise/BTProgressHUD
13 | */
14 |
15 | namespace BTProgressHUDDemo
16 | {
17 | public class MainViewController : UIViewController
18 | {
19 | public MainViewController ()
20 | {
21 |
22 | }
23 | UITextView text;
24 | float progress = -1;
25 | NSTimer timer;
26 | public override void LoadView ()
27 | {
28 | base.LoadView ();
29 | View.BackgroundColor = UIColor.LightGray;
30 |
31 | MakeButton ("Show", () => {
32 | BTProgressHUD.Show ();
33 | KillAfter ();
34 | });
35 |
36 | MakeButton ("Show Message", () => {
37 | BTProgressHUD.Show (status: "Processing your image");
38 | KillAfter ();
39 | });
40 |
41 | MakeButton ("Show Success", () => {
42 | BTProgressHUD.ShowSuccessWithStatus("Great success!") ;
43 | });
44 |
45 | MakeButton ("Show Fail", () => {
46 | BTProgressHUD.ShowErrorWithStatus("Oh, thats bad") ;
47 | });
48 |
49 | MakeButton ("Toast", () => {
50 | BTProgressHUD.ShowToast("Hello from the toast", showToastCentered: false) ;
51 |
52 | });
53 |
54 |
55 | MakeButton ("Dismiss", () => {
56 | BTProgressHUD.Dismiss ();
57 | });
58 |
59 | MakeButton ("Progress", () => {
60 | progress = 0;
61 | BTProgressHUD.Show("Hello!", progress);
62 | if (timer != null)
63 | {
64 | timer.Invalidate();
65 | }
66 | timer = NSTimer.CreateRepeatingTimer(0.5f, delegate {
67 | progress += 0.1f;
68 | if (progress > 1)
69 | {
70 | timer.Invalidate();
71 | timer = null;
72 | BTProgressHUD.Dismiss();
73 | } else {
74 | BTProgressHUD.Show ("Hello!", progress);
75 | }
76 |
77 |
78 | });
79 | NSRunLoop.Current.AddTimer(timer, NSRunLoopMode.Common);
80 | });
81 |
82 | MakeButton ("Dismiss", () => {
83 | BTProgressHUD.Dismiss ();
84 | });
85 |
86 | }
87 |
88 | void KillAfter (float timeout = 1)
89 | {
90 | if (timer != null)
91 | {
92 | timer.Invalidate();
93 | }
94 | timer = NSTimer.CreateRepeatingTimer(timeout, delegate {
95 | BTProgressHUD.Dismiss();
96 | });
97 | NSRunLoop.Current.AddTimer(timer, NSRunLoopMode.Common);
98 | }
99 | float y = 20;
100 | void MakeButton(string text, Action del)
101 | {
102 | float x = 20;
103 |
104 | var button = new UIButton (UIButtonType.RoundedRect);
105 | button.Frame = new RectangleF (x, y, 280, 40);
106 | button.SetTitle (text, UIControlState.Normal);
107 | button.TouchUpInside += (o,e) => {
108 | del() ;
109 | };
110 | View.Add (button);
111 |
112 |
113 | y += 45;
114 |
115 | }
116 |
117 | public override void ViewDidLoad ()
118 | {
119 | base.ViewDidLoad ();
120 |
121 | }
122 |
123 | public override void ViewDidAppear (bool animated)
124 | {
125 | base.ViewDidAppear (animated);
126 |
127 | }
128 | }
129 | }
130 |
131 |
--------------------------------------------------------------------------------
/iOS/FormViewController.designer.cs:
--------------------------------------------------------------------------------
1 | // WARNING
2 | //
3 | // This file has been generated automatically by Xamarin Studio to store outlets and
4 | // actions made in the UI designer. If it is removed, they will be lost.
5 | // Manual changes to this file may not be handled correctly.
6 | //
7 | using MonoTouch.Foundation;
8 | using System.CodeDom.Compiler;
9 |
10 | namespace AltinnApp.iOS
11 | {
12 | [Register ("FormViewController")]
13 | partial class FormViewController
14 | {
15 | [Outlet]
16 | MonoTouch.UIKit.UILabel _goToInbox { get; set; }
17 |
18 | [Outlet]
19 | MonoTouch.UIKit.UILabel _header { get; set; }
20 |
21 | [Outlet]
22 | MonoTouch.UIKit.UILabel _infoBox { get; set; }
23 |
24 | [Outlet]
25 | MonoTouch.UIKit.UILabel _lastChangedBy { get; set; }
26 |
27 | [Outlet]
28 | MonoTouch.UIKit.UILabel _lastChangedByLabel { get; set; }
29 |
30 | [Outlet]
31 | MonoTouch.UIKit.UILabel _lastChangedDate { get; set; }
32 |
33 | [Outlet]
34 | MonoTouch.UIKit.UILabel _lastChangedDateLabel { get; set; }
35 |
36 | [Outlet]
37 | MonoTouch.UIKit.UIButton _printIcon { get; set; }
38 |
39 | [Outlet]
40 | MonoTouch.UIKit.UILabel _printLabel { get; set; }
41 |
42 | [Outlet]
43 | MonoTouch.UIKit.UILabel _recipient { get; set; }
44 |
45 | [Outlet]
46 | MonoTouch.UIKit.UILabel _recipientLabel { get; set; }
47 |
48 | [Outlet]
49 | MonoTouch.UIKit.UILabel _subject { get; set; }
50 |
51 | [Action ("GoBack:")]
52 | partial void GoBack (MonoTouch.Foundation.NSObject sender);
53 |
54 | [Action ("HandleSwipeRight:")]
55 | partial void HandleSwipeRight (MonoTouch.Foundation.NSObject sender);
56 |
57 | [Action ("OpenPrint:")]
58 | partial void OpenPrint (MonoTouch.Foundation.NSObject sender);
59 |
60 | void ReleaseDesignerOutlets ()
61 | {
62 | if (_subject != null) {
63 | _subject.Dispose ();
64 | _subject = null;
65 | }
66 |
67 | if (_lastChangedBy != null) {
68 | _lastChangedBy.Dispose ();
69 | _lastChangedBy = null;
70 | }
71 |
72 | if (_recipientLabel != null) {
73 | _recipientLabel.Dispose ();
74 | _recipientLabel = null;
75 | }
76 |
77 | if (_lastChangedDate != null) {
78 | _lastChangedDate.Dispose ();
79 | _lastChangedDate = null;
80 | }
81 |
82 | if (_recipient != null) {
83 | _recipient.Dispose ();
84 | _recipient = null;
85 | }
86 |
87 | if (_lastChangedByLabel != null) {
88 | _lastChangedByLabel.Dispose ();
89 | _lastChangedByLabel = null;
90 | }
91 |
92 | if (_lastChangedDateLabel != null) {
93 | _lastChangedDateLabel.Dispose ();
94 | _lastChangedDateLabel = null;
95 | }
96 |
97 | if (_goToInbox != null) {
98 | _goToInbox.Dispose ();
99 | _goToInbox = null;
100 | }
101 |
102 | if (_header != null) {
103 | _header.Dispose ();
104 | _header = null;
105 | }
106 |
107 | if (_infoBox != null) {
108 | _infoBox.Dispose ();
109 | _infoBox = null;
110 | }
111 |
112 | if (_printIcon != null) {
113 | _printIcon.Dispose ();
114 | _printIcon = null;
115 | }
116 |
117 | if (_printLabel != null) {
118 | _printLabel.Dispose ();
119 | _printLabel = null;
120 | }
121 | }
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 | [Dd]ebug/
11 | [Dd]ebugPublic/
12 | [Rr]elease/
13 | x64/
14 | build/
15 | bld/
16 | [Bb]in/
17 | [Oo]bj/
18 |
19 | # MSTest test Results
20 | [Tt]est[Rr]esult*/
21 | [Bb]uild[Ll]og.*
22 |
23 | #NUNIT
24 | *.VisualState.xml
25 | TestResult.xml
26 |
27 | # Build Results of an ATL Project
28 | [Dd]ebugPS/
29 | [Rr]eleasePS/
30 | dlldata.c
31 |
32 | *_i.c
33 | *_p.c
34 | *_i.h
35 | *.ilk
36 | *.meta
37 | *.obj
38 | *.pch
39 | *.pdb
40 | *.pgc
41 | *.pgd
42 | *.rsp
43 | *.sbr
44 | *.tlb
45 | *.tli
46 | *.tlh
47 | *.tmp
48 | *.tmp_proj
49 | *.log
50 | *.vspscc
51 | *.vssscc
52 | .builds
53 | *.pidb
54 | *.svclog
55 | *.scc
56 |
57 | # Chutzpah Test files
58 | _Chutzpah*
59 |
60 | # Visual C++ cache files
61 | ipch/
62 | *.aps
63 | *.ncb
64 | *.opensdf
65 | *.sdf
66 | *.cachefile
67 |
68 | # Visual Studio profiler
69 | *.psess
70 | *.vsp
71 | *.vspx
72 |
73 | # TFS 2012 Local Workspace
74 | $tf/
75 |
76 | # Guidance Automation Toolkit
77 | *.gpState
78 |
79 | # ReSharper is a .NET coding add-in
80 | _ReSharper*/
81 | *.[Rr]e[Ss]harper
82 | *.DotSettings.user
83 |
84 | # JustCode is a .NET coding addin-in
85 | .JustCode
86 |
87 | # TeamCity is a build add-in
88 | _TeamCity*
89 |
90 | # DotCover is a Code Coverage Tool
91 | *.dotCover
92 |
93 | # NCrunch
94 | *.ncrunch*
95 | _NCrunch_*
96 | .*crunch*.local.xml
97 |
98 | # MightyMoose
99 | *.mm.*
100 | AutoTest.Net/
101 |
102 | # Web workbench (sass)
103 | .sass-cache/
104 |
105 | # Installshield output folder
106 | [Ee]xpress/
107 |
108 | # DocProject is a documentation generator add-in
109 | DocProject/buildhelp/
110 | DocProject/Help/*.HxT
111 | DocProject/Help/*.HxC
112 | DocProject/Help/*.hhc
113 | DocProject/Help/*.hhk
114 | DocProject/Help/*.hhp
115 | DocProject/Help/Html2
116 | DocProject/Help/html
117 |
118 | # Click-Once directory
119 | publish/
120 |
121 | # Publish Web Output
122 | *.[Pp]ublish.xml
123 | *.azurePubxml
124 |
125 | # NuGet Packages Directory
126 | packages/
127 | ## TODO: If the tool you use requires repositories.config uncomment the next line
128 | #!packages/repositories.config
129 |
130 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
131 | # This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
132 | !packages/build/
133 |
134 | # Windows Azure Build Output
135 | csx/
136 | *.build.csdef
137 |
138 | # Windows Store app package directory
139 | AppPackages/
140 |
141 | # Others
142 | sql/
143 | *.Cache
144 | ClientBin/
145 | [Ss]tyle[Cc]op.*
146 | ~$*
147 | *~
148 | *.dbmdl
149 | *.dbproj.schemaview
150 | *.pfx
151 | *.publishsettings
152 | node_modules/
153 |
154 | # RIA/Silverlight projects
155 | Generated_Code/
156 |
157 | # Backup & report files from converting an old project file to a newer
158 | # Visual Studio version. Backup files are not needed, because we have git ;-)
159 | _UpgradeReport_Files/
160 | Backup*/
161 | UpgradeLog*.XML
162 | UpgradeLog*.htm
163 |
164 | # SQL Server files
165 | *.mdf
166 | *.ldf
167 |
168 | # Business Intelligence projects
169 | *.rdl.data
170 | *.bim.layout
171 | *.bim_*.settings
172 |
173 | # Microsoft Fakes
174 | FakesAssemblies/
175 |
--------------------------------------------------------------------------------
/Core/Util/ErrorMessages.cs:
--------------------------------------------------------------------------------
1 | namespace AltinnApp.Core.Util
2 | {
3 | ///
4 | /// Class holding error codes. Can be localized as needed.
5 | ///
6 | public static class ErrorMessages
7 | {
8 | ///
9 | /// Enums of network conditions that might occur
10 | ///
11 | public enum Network
12 | {
13 | ///
14 | /// Invalid authentication
15 | ///
16 | InvalidAuthSession,
17 |
18 | ///
19 | /// Connection error
20 | ///
21 | ConnectionError
22 | }
23 |
24 | public const string RemoteMessageError = "RemoteMessageError";
25 |
26 | ///
27 | /// Enum of Service conditions that might occur
28 | ///
29 | public enum Service
30 | {
31 | ///
32 | /// Invalid authentication
33 | ///
34 | InvalidAuthSession,
35 |
36 | ///
37 | /// Connection error
38 | ///
39 | ConnectionError,
40 |
41 | ///
42 | /// No support for BankID
43 | ///
44 | BankIDNotSupported
45 | }
46 |
47 | public static string MustOverride = "Must override DownloadData";
48 |
49 | ///
50 | /// General "could not connect" message
51 | ///
52 | public const string ConnectionFailed = "ConnectionFailed";
53 |
54 | ///
55 | /// General "could not connect" message
56 | ///
57 | public const string GeneralError = "GeneralError";
58 |
59 | ///
60 | /// General "could not connect" message
61 | ///
62 | //public const string SerializationError = "En feil oppstod under tolking av data, vennligst prøv igjen";
63 | ///
64 | /// Failed to show the print view
65 | ///
66 | public const string PrintFailed = "PrintError";
67 |
68 | public const string SerializationError = "SerializationError";
69 |
70 | ///
71 | /// Critical error occured, abort
72 | ///
73 | /// The critical error.
74 | public const string CriticalError = "CriticalError";
75 |
76 | ///
77 | /// 401 gets returned if the user has insufficient authorization level. With "MinID" it is level 3, with "BankID" it is
78 | /// level 4
79 | ///
80 | public const string InsufficientAuthorization = "InsufficientAuthorization";
81 |
82 | //"Du har for lavt sikkerhetsnivå for å lese denne meldingen, for å lese den må du logge inn på ny med {0}";
83 |
84 | ///
85 | /// Not logged in error
86 | ///
87 | //public static string NotLoggedIn = "Innloggingen har timet ut, logg inn på ny for å fortsette";
88 | ///
89 | /// BankID not supported error
90 | ///
91 | public const string BankIDNotSupported = "BankIDNotSupported";
92 |
93 | ///
94 | /// Network not available error
95 | ///
96 | public const string NoNetworkAvailable = "NoNetworkAvailable";
97 | }
98 | }
--------------------------------------------------------------------------------
/iOS/FeedbackController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using AltinnApp.Core.Util;
3 | using MonoTouch.Foundation;
4 | using MonoTouch.MessageUI;
5 | using MonoTouch.UIKit;
6 | using SWRevealViewControllerBinding;
7 | using AltinnApp.Core.Models;
8 |
9 | namespace AltinnApp.iOS
10 | {
11 | public partial class FeedbackController : UIViewController
12 | {
13 | private CorePlatform.Translate _trans;
14 |
15 | public FeedbackController(IntPtr handle)
16 | : base(handle)
17 | {
18 | }
19 |
20 | public override void ViewDidLoad()
21 | {
22 | base.ViewDidLoad();
23 | if (this.RevealViewController() != null)
24 | {
25 | _gobackButton.TouchUpInside += (sender, e) => this.RevealViewController().RevealToggleAnimated(true);
26 | View.AddGestureRecognizer(this.RevealViewController().PanGestureRecognizer);
27 |
28 | //Popout from Flyout
29 | // mailController.ModalInPopover = true;
30 | // mailController.SetToRecipients(new[] { "app@altinn.no" });
31 | // mailController.SetSubject("Altinn hjelp");
32 | // mailController.SetMessageBody("Ansvarsfraskrivelse av Altinn!", true);
33 | //
34 | // mailController.Finished += (s, args) =>
35 | // {
36 | // Logger.Logg(args.Result.ToString());
37 | //
38 | // this.RevealViewController().RevealToggleAnimated(true);
39 | // args.Controller.DismissViewController(false, null);
40 | // //this.RevealViewController().SetFrontViewController(this.RevealViewController().RearViewController, true);
41 | // };
42 | //
43 | // //this.RevealViewController ().SetFrontViewController (mailController, true);
44 | //
45 | // mailController.ModalInPopover = true;
46 | // // this.RevealViewController().SetFrontViewController(mailController, false);
47 | // this.RevealViewController().PresentModalViewController(mailController, false);
48 | _trans = new CorePlatform.Translate();
49 |
50 | Localize();
51 | }
52 | }
53 |
54 | ///
55 | /// Localize the strings in this controller
56 | ///
57 | private void Localize()
58 | {
59 | _bodyHeader.Text = _trans.GetString("FeedbackController_BodyHeader");
60 | _body.Text = _trans.GetString("FeedbackController_Body");
61 | _header.Text = _trans.GetString("FeedbackController_Header");
62 | }
63 |
64 | // ReSharper disable once UnusedMember.Local
65 | // ReSharper disable once UnusedParameter.Local
66 | partial void SendMail(NSObject sender)
67 | {
68 | var mailController = new MFMailComposeViewController();
69 |
70 | mailController.SetToRecipients(new[]
71 | {
72 | Constants.FeedbackMail
73 | });
74 | mailController.SetSubject(_trans.GetString("FeedbackController_MailTitle"));
75 |
76 |
77 | mailController.Finished += (s, args) =>
78 | {
79 | Logger.Logg(args.Result.ToString());
80 | args.Controller.DismissViewController(true, null);
81 | };
82 |
83 | PresentViewController(mailController, true, null);
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/Core/Util/Serializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using AltinnApp.Core.Models;
5 | using Newtonsoft.Json;
6 | using Newtonsoft.Json.Linq;
7 |
8 | namespace AltinnApp.Core.Util
9 | {
10 | ///
11 | /// Class for de-serializing JSON data
12 | ///
13 | public static class Serializer
14 | {
15 | ///
16 | /// De-serialize the HAL-JSON returned from the API to an object
17 | ///
18 | ///
19 | ///
20 | public static Message DeserializeMessage(string jsonMessage)
21 | {
22 | Message newMessage = null;
23 |
24 | try
25 | {
26 | newMessage = JsonConvert.DeserializeObject(jsonMessage);
27 | }
28 | catch (Exception e)
29 | {
30 | Logger.Logg("Failed to de-serialize the message: ", e);
31 | }
32 |
33 | return newMessage;
34 | }
35 |
36 | ///
37 | /// De-serialize the messagebox from JSON
38 | ///
39 | ///
40 | ///
41 | public static List DeserializeMessagebox(string json)
42 | {
43 | var mess = new List();
44 | try
45 | {
46 | if (!string.IsNullOrEmpty(json))
47 | {
48 | var outer = JsonConvert.DeserializeObject(json);
49 | JObject innerObjectJson = outer._embedded;
50 | JToken messages = innerObjectJson["messages"];
51 | mess = messages.ToObject>().ToList();
52 | }
53 | }
54 | catch (Exception e)
55 | {
56 | Logger.Logg("Failed to deserialize Json: ", e);
57 | }
58 |
59 | return mess;
60 | }
61 |
62 | ///
63 | /// De-serialize the list of reportees from JSON
64 | ///
65 | ///
66 | ///
67 | public static List DeserializeOrganizations(string json)
68 | {
69 | var orgs = new List();
70 | try
71 | {
72 | var outerOrg = JsonConvert.DeserializeObject(json);
73 | JObject innerObjectJsonOrg = outerOrg._embedded;
74 | JToken orgMessages = innerObjectJsonOrg["organizations"];
75 | orgs = orgMessages.ToObject>().ToList();
76 | }
77 | catch (Exception e)
78 | {
79 | Logger.Logg("Failed to deserialize Json: ", e);
80 | }
81 |
82 | return orgs;
83 | }
84 |
85 | public static Profile DeserializeProfile(string profileJSON)
86 | {
87 | var prof = new Profile();
88 | try
89 | {
90 | prof = JsonConvert.DeserializeObject(profileJSON);
91 | //JObject innerObjectJsonOrg = outerOrg._embedded;
92 | //JToken orgMessages = innerObjectJsonOrg["organizations"];
93 | //prof = orgMessages.ToObject();
94 | }
95 | catch (Exception e)
96 | {
97 | Logger.Logg("Failed to deserialize Json: ", e);
98 | }
99 | return prof;
100 | }
101 | }
102 | }
--------------------------------------------------------------------------------
/iOS/Components/btprogresshud-1.9.info:
--------------------------------------------------------------------------------
1 | {"Name":"BTProgressHUD","Id":535,"Alias":"btprogresshud","Description":"BTProgressHUD is a HUD - heads up display - for your application. It allows you to show transient information to the user, to keep them informed of longer running tasks and alerts.\n\nBTProgressHUD is based on the iOS [SVProgressHUD](https://github.com/samvermette/SVProgressHUD) project.\n\n```csharp\nusing BigTed;\n...\n\npublic override void ViewDidAppear (bool animated)\n{\n\tbase.ViewDidAppear (animated);\n\t\n\t//Show a HUD with a progress spinner and the text\n\tBTProgressHUD.Show(\"Hello there!\");\n\t\n\t//you will need to hide it somewhere else\n\t//BTProgressHUD.Dismiss();\n}\n\n```\n\nThere are other forms of HUD: \n\n* Spinner only\n* Spinner and text\n* Progress\n* Image and text\n* Toast, modelled after the [Android Toast](http://developer.android.com/guide/topics/ui/notifiers/toasts.html) display.\n\nSource code can be found on [GitHub](https://github.com/nicwise/BTProgressHUD/).\nAny bugs, file them on GitHub and [drop me an email](mailto:nicw@fastchicken.co.nz)\n\nSome screenshots assembled with [PlaceIt](http://placeit.breezi.com/).\n","Version":"1.9","Summary":"Add awesome HUDs to your iOS apps.","QuickStart":"#Usage\n\nHave a look at the BTProgressHUDDemo project.\n\nFirstly, you need to use the BigTed namespace\n\n```csharp\nusing BigTed;\n```\n\nThen, there are a few main static methods for showing the HUD:\n\n```csharp\nBTProgressHUD.Show(); //shows the spinner\nBTProgressHUD.Show(\"Oh hai\"); //show spinner + text\nBTProgressHUD.ShowSuccessWithStatus(\"Wow, that worked\"); //A big TICK with text\nBTProgressHUD.ShowErrorWithStatus(\"Fail!\"); //A big CROSS with text\nBTProgressHUD.ShowToast(\"Hello from Toast\"); //show an Android-style toast\n```\nAll of these can be dismissed, once your processing is finished, with\n\n```csharp\nBTProgressHUD.Dismiss();\n```\n\nShowToast, ShowSuccessWithStatus, ShowErrorWithStatus, and ShowImage all auto-dismiss.\n\nBTProgressHUD is aware of the thread you are calling from, and ensures that HUDs are always manipulated from the UI thread.\n\n#Using on iOS6\n\nIf your app needs to work against the iOS6 SDK, but with the user on iOS7, you can set \n\n```csharp\nBTProgressHUD.ForceiOS6LookAndFeel = true;\n```\n\nAnd all the dialog boxes will look like iOS6 (black with white text, not the other way)\n\n#Other Show options\n\nYou can call Show with the following parameters\n\n* status: \u003cstring\u003e - show status text\n* progress: \u003cfloat\u003e - show a progress circle with 0.0 - 1.0 of progress. Call again to change the progress.\n* maskType: \u003cProgressHUD.MaskType\u003e - show with the background (the whole window) clear, black or gradient. Default is none, which allows interaction with the underlying elements.\n\n```csharp\npublic enum MaskType\n{\n\tNone = 1, // allow user interactions, don\u0027t dim background UI (default)\n\tClear, // disable user interactions, don\u0027t dim background UI\n\tBlack, // disable user interactions, dim background UI with 50% translucent black\n\tGradient // disable user interactions, dim background UI with translucent radial gradient (a-la-alertView)\n}\n```\n\n#ShowToast\nThe toast can be centered or at the bottom of the screen, like Android. This is controlled by the second parameter.\n\n```csharp\nBTProgressHUD.ShowToast (\"Your download finished\", showToastCentered: false);\n```\n\n#ShowSuccess/Error/ShowImage\nThis method dismisses the activity after 1 second. You can provide your own images if needed - make them 28x28 white PNGs.\n\n```csharp\nBTProgressHUD.ShowSuccessWithStatus (\"Wow, that worked\"); //A big TICK with text\nBTProgressHUD.ShowErrorWithStatus (\"Fail!\"); //A big CROSS with text\nBTProgressHUD.ShowImage (UIImage.FromFile(\"an-image-file.png\"), \"Nice one Stu!\");\n```\n\nYou can use the timeout parameter of ShowImage to control the time before it\u0027s dismissed.\n\n# Other Resources\n\n* [Source code](https://github.com/nicwise/BTProgressHUD/)\n","Hash":"42dee51978f92507143d19227a8c8fb0","TargetPlatforms":["ios"],"TrialHash":null}
--------------------------------------------------------------------------------
/iOS/ContactController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using AltinnApp.Core.Util;
3 | using MonoTouch.Foundation;
4 | using MonoTouch.MessageUI;
5 | using MonoTouch.UIKit;
6 | using SWRevealViewControllerBinding;
7 |
8 | namespace AltinnApp.iOS
9 | {
10 | public partial class ContactController : UIViewController
11 | {
12 | private CorePlatform.Translate _trans;
13 |
14 | public ContactController(IntPtr handle)
15 | : base(handle)
16 | {
17 | }
18 |
19 | private void Localize()
20 | {
21 | _header.Text = _trans.GetString("ContactController_Header");
22 | _bodyTopHeader.Text = _trans.GetString("ContactController_BodyTopHeader");
23 | _bodyTop.Text = _trans.GetString("ContactController_BodyTop");
24 | _bodyBottomHeader.Text = _trans.GetString("ContactController_BodyBottomHeader");
25 | _bodyBottom.Text = _trans.GetString("ContactController_BodyBottom");
26 | }
27 |
28 | public override void ViewDidLoad()
29 | {
30 | base.ViewDidLoad();
31 | if (this.RevealViewController() != null)
32 | {
33 | _gobackButton.TouchUpInside += (sender, e) => this.RevealViewController().RevealToggleAnimated(true);
34 | View.AddGestureRecognizer(this.RevealViewController().PanGestureRecognizer);
35 | }
36 |
37 | //_contactTlf.TitleLabel.Text = Constants.ContactSupportTlf;
38 | //_contactMail.TitleLabel.Text = Constants.ContactSupportTlf;
39 | _trans = new CorePlatform.Translate();
40 | Localize();
41 | }
42 |
43 | // ReSharper disable once UnusedMember.Local
44 | // ReSharper disable once UnusedParameter.Local
45 | partial void OpenFacebook(NSObject sender)
46 | {
47 | var nsurl = new NSUrl("fb://profile/214112901961006");
48 | if (UIApplication.SharedApplication.CanOpenUrl(nsurl))
49 | {
50 | UIApplication.SharedApplication.OpenUrl(nsurl);
51 | }
52 | else
53 | {
54 | Util.Util.ShowAlert(_trans.GetString("Error_MissingFBApp"));
55 | }
56 | }
57 |
58 | // ReSharper disable once UnusedMember.Local
59 | // ReSharper disable once UnusedParameter.Local
60 | partial void OpenTwitter(NSObject sender)
61 | {
62 | var nsurl = new NSUrl("twitter://user?screen_name=Altinn");
63 | if (UIApplication.SharedApplication.CanOpenUrl(nsurl))
64 | {
65 | UIApplication.SharedApplication.OpenUrl(nsurl);
66 | }
67 | else
68 | {
69 | Util.Util.ShowAlert(_trans.GetString("Error_MissingFBApp"));
70 | }
71 | }
72 |
73 | // ReSharper disable once UnusedMember.Local
74 | // ReSharper disable once UnusedParameter.Local
75 | partial void Call(NSObject sender)
76 | {
77 | string tlf = "tel://" + Constants.ContactSupportTlf.Trim().Replace(" ", "");
78 | var url = new NSUrl(tlf);
79 | UIApplication.SharedApplication.OpenUrl(url);
80 | }
81 |
82 | // ReSharper disable once UnusedMember.Local
83 | // ReSharper disable once UnusedParameter.Local
84 | partial void SendMail(NSObject sender)
85 | {
86 | var mailController = new MFMailComposeViewController();
87 |
88 | mailController.SetToRecipients(new[]
89 | {
90 | "support@altinn.no"
91 | });
92 | mailController.SetSubject(_trans.GetString("ContactController_MailTitle"));
93 |
94 |
95 | mailController.Finished += (s, args) =>
96 | {
97 |
98 | args.Controller.DismissViewController(true, null);
99 | };
100 |
101 | PresentViewController(mailController, true, null);
102 | }
103 | }
104 | }
--------------------------------------------------------------------------------
/iOS/SettingsController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MonoTouch.UIKit;
3 | using SWRevealViewControllerBinding;
4 | using MonoTouch.Foundation;
5 | using AltinnApp.Core.Models;
6 |
7 | namespace AltinnApp.iOS
8 | {
9 | public partial class SettingsController : UIViewController
10 | {
11 | private CorePlatform.Translate _trans;
12 |
13 | public SettingsController(IntPtr handle)
14 | : base(handle)
15 | {
16 | }
17 |
18 | public override void ViewDidLoad()
19 | {
20 | base.ViewDidLoad();
21 | tableView.WeakDataSource = tableView.WeakDelegate = this;
22 | if (this.RevealViewController() != null)
23 | {
24 | _gobackButton.TouchUpInside += (sender, e) => this.RevealViewController().RevealToggleAnimated(true);
25 | View.AddGestureRecognizer(this.RevealViewController().PanGestureRecognizer);
26 | }
27 | _trans = new CorePlatform.Translate();
28 | Localize();
29 | }
30 |
31 | public override void ViewWillAppear(bool animated)
32 | {
33 | base.ViewWillAppear(animated);
34 | Localize();
35 |
36 | tableView.ReloadData();
37 | }
38 |
39 | [Export("tableView:numberOfRowsInSection:")]
40 | public int RowsInSection(UITableView tableview, int section)
41 | {
42 | return 1;
43 | }
44 |
45 | [Export("tableView:cellForRowAtIndexPath:")]
46 | // ReSharper disable once ParameterHidesMember
47 | public UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
48 | {
49 | const string cellName = "LanguageCell";
50 | var cell = tableView.DequeueReusableCell(cellName) as SettingsCell ?? new SettingsCell();
51 | cell.UpdateCell();
52 | return cell;
53 | }
54 |
55 | ///
56 | /// Localize the strings in this controller
57 | ///
58 | private void Localize()
59 | {
60 | _header.Text = _trans.GetString("SettingsController_Header");
61 | }
62 |
63 | [Export("tableView:didSelectRowAtIndexPath:")]
64 | // ReSharper disable once ParameterHidesMember
65 | public void RowSelected(UITableView tableView, NSIndexPath indexPath)
66 | {
67 | if (indexPath.Row == 0)
68 | {
69 | var prompt = new UIAlertView(string.Empty, _trans.GetString("Popup_SelectLanguage"), null,
70 | _trans.GetString("Misc_Cancel"),
71 | new[]
72 | {
73 | _trans.GetString("Misc_Lang_Bokmaal"), _trans.GetString("Misc_Lang_Nynorsk"),
74 | _trans.GetString("Misc_Lang_English")
75 | })
76 | {
77 | AlertViewStyle = UIAlertViewStyle.Default
78 | };
79 |
80 |
81 | prompt.Clicked += (s, b) =>
82 | {
83 | if (b.ButtonIndex == 0)
84 | {
85 | }
86 | else if (b.ButtonIndex == 1)
87 | {
88 | AppContext.CurrentCulture = "nb-NO";
89 | AppContext.CurrentLanguage = "1044";
90 | }
91 | else if (b.ButtonIndex == 2)
92 | {
93 | AppContext.CurrentCulture = "nn-NO";
94 | AppContext.CurrentLanguage = "2068";
95 | }
96 | else if (b.ButtonIndex == 3)
97 | {
98 | AppContext.CurrentCulture = "en";
99 | AppContext.CurrentLanguage = "1033";
100 | }
101 | Util.Util.SetLanguage();
102 | Localize();
103 | tableView.ReloadData();
104 | };
105 | prompt.Show();
106 | }
107 | }
108 | }
109 | }
--------------------------------------------------------------------------------
/iOS/CorePlatform/PlattformDAL.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using System.Net.Security;
4 | using System.Security.Cryptography.X509Certificates;
5 | using AltinnApp.Core.DAL;
6 | using AltinnApp.Core.Models;
7 | using AltinnApp.Core.Util;
8 | using AltinnApp.iOS.Util;
9 | using System.Threading.Tasks;
10 |
11 | namespace AltinnApp.iOS.CorePlatform
12 | {
13 | ///
14 | /// Inherited class of the Core.DAL to provide the appropiate client transfer mechanism.
15 | /// This subclass also allows us to override the ICertificatePolicy. It is very important to NOT override this for the production release since it
16 | /// opens the door to many security threats
17 | ///
18 | internal class PlattformDAL : Data//, ICertificatePolicy
19 | {
20 | ///
21 | /// Default constructor for the platform specific DAL
22 | ///
23 | public PlattformDAL()
24 | {
25 | //ServicePointManager.ServerCertificateValidationCallback = Validator;
26 | }
27 |
28 | #region RemoveInProductionRelease
29 |
30 | ///
31 | /// Override implementation of Validator to accept non-valid certificates to enable self-signed certificates in test environments
32 | ///
33 | ///
34 | ///
35 | ///
36 | ///
37 | ///
38 | ///
39 | public static bool Validator(object sender, X509Certificate certificate, X509Chain chain,
40 | SslPolicyErrors sslPolicyErrors)
41 | {
42 | return true;
43 | }
44 |
45 | ///
46 | /// Override of CheckValidationResult to accept non-valid certificates to enable self-signed certificates in test environments
47 | ///
48 | ///
49 | ///
50 | ///
51 | ///
52 | ///
53 | public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request,
54 | int certificateProblem)
55 | {
56 | return true;
57 | }
58 |
59 | #endregion
60 |
61 | protected override async Task SetupAndDownloadData(string uri)
62 | {
63 |
64 | //return base.SetupAndDownloadData(uri);
65 | var ws = new WebClient();
66 |
67 | ws.Headers.Add("Cookie", Session.CookieJar.ToString());
68 | ws.Headers.Add("ApiKey", AppContext.ApiKey);
69 |
70 | Byte[] res = null;
71 |
72 | if (Reachability.IsHostReachable(uri))
73 | {
74 | res = await ws.DownloadDataTaskAsync(uri);
75 | }
76 | else
77 | {
78 | throw new AppException(ErrorMessages.ConnectionFailed, "0");
79 | }
80 |
81 | return res;
82 | }
83 |
84 | protected override async Task SetupAndDownloadString(string uri)
85 | {
86 | if (uri.IndexOf ("?") < 0) {
87 | uri += "?language=" + AppContext.CurrentLanguage;
88 | } else {
89 | uri += "&language=" + AppContext.CurrentLanguage;
90 | }
91 |
92 | var ws = new WebClient();
93 |
94 | ws.Headers.Add("Cookie", Session.CookieJar.ToString());
95 | ws.Headers.Add("ApiKey", AppContext.ApiKey);
96 | ws.Headers.Add("Accept", Constants.ApiFormat);
97 |
98 | string res = null;
99 |
100 | if (Reachability.IsHostReachable(uri))
101 | {
102 | res = await ws.DownloadStringTaskAsync(uri);
103 | }
104 | else
105 | {
106 | throw new AppException(ErrorMessages.ConnectionFailed, "0");
107 | }
108 |
109 | return res;
110 | }
111 | }
112 | }
--------------------------------------------------------------------------------
/iOS/CorrespondenceViewController.designer.cs:
--------------------------------------------------------------------------------
1 | // WARNING
2 | //
3 | // This file has been generated automatically by Xamarin Studio to store outlets and
4 | // actions made in the UI designer. If it is removed, they will be lost.
5 | // Manual changes to this file may not be handled correctly.
6 | //
7 | using MonoTouch.Foundation;
8 | using System.CodeDom.Compiler;
9 |
10 | namespace AltinnApp.iOS
11 | {
12 | [Register ("CorrespondenceViewController")]
13 | partial class CorrespondenceViewController
14 | {
15 | [Outlet]
16 | MonoTouch.UIKit.UIButton _attachmentIcon { get; set; }
17 |
18 | [Outlet]
19 | MonoTouch.UIKit.UILabel _attachmentLabel { get; set; }
20 |
21 | [Outlet]
22 | MonoTouch.UIKit.UILabel _createdDate { get; set; }
23 |
24 | [Outlet]
25 | MonoTouch.UIKit.UILabel _DateReceivedLabel { get; set; }
26 |
27 | [Outlet]
28 | MonoTouch.UIKit.UILabel _header { get; set; }
29 |
30 | [Outlet]
31 | MonoTouch.UIKit.UILabel _recipient { get; set; }
32 |
33 | [Outlet]
34 | MonoTouch.UIKit.UILabel _sender { get; set; }
35 |
36 | [Outlet]
37 | MonoTouch.UIKit.UILabel _SenderLabel { get; set; }
38 |
39 | [Outlet]
40 | MonoTouch.UIKit.UIButton _sendToMailIcon { get; set; }
41 |
42 | [Outlet]
43 | MonoTouch.UIKit.UILabel _sendToMailLabel { get; set; }
44 |
45 | [Outlet]
46 | MonoTouch.UIKit.UIImageView _separatorImageBottom { get; set; }
47 |
48 | [Outlet]
49 | MonoTouch.UIKit.UIImageView _separatorImageTop { get; set; }
50 |
51 | [Outlet]
52 | MonoTouch.UIKit.UILabel _serviceOwner { get; set; }
53 |
54 | [Outlet]
55 | MonoTouch.UIKit.UILabel _subject { get; set; }
56 |
57 | [Outlet]
58 | MonoTouch.UIKit.UILabel _summaryLabel { get; set; }
59 |
60 | [Outlet]
61 | MonoTouch.UIKit.UILabel GoToInbox { get; set; }
62 |
63 | [Outlet]
64 | MonoTouch.UIKit.UIButton[] OpenAttachment { get; set; }
65 |
66 | [Outlet]
67 | MonoTouch.UIKit.UIWebView webview { get; set; }
68 |
69 | [Action ("GoBack:")]
70 | partial void GoBack (MonoTouch.Foundation.NSObject sender);
71 |
72 | [Action ("HandleSwipeRight:")]
73 | partial void HandleSwipeRight (MonoTouch.Foundation.NSObject sender);
74 |
75 | [Action ("SendToMail:")]
76 | partial void SendToMail (MonoTouch.Foundation.NSObject sender);
77 |
78 | void ReleaseDesignerOutlets ()
79 | {
80 | if (_header != null) {
81 | _header.Dispose ();
82 | _header = null;
83 | }
84 |
85 | if (_DateReceivedLabel != null) {
86 | _DateReceivedLabel.Dispose ();
87 | _DateReceivedLabel = null;
88 | }
89 |
90 | if (_SenderLabel != null) {
91 | _SenderLabel.Dispose ();
92 | _SenderLabel = null;
93 | }
94 |
95 | if (_attachmentIcon != null) {
96 | _attachmentIcon.Dispose ();
97 | _attachmentIcon = null;
98 | }
99 |
100 | if (_attachmentLabel != null) {
101 | _attachmentLabel.Dispose ();
102 | _attachmentLabel = null;
103 | }
104 |
105 | if (_createdDate != null) {
106 | _createdDate.Dispose ();
107 | _createdDate = null;
108 | }
109 |
110 | if (_recipient != null) {
111 | _recipient.Dispose ();
112 | _recipient = null;
113 | }
114 |
115 | if (_sender != null) {
116 | _sender.Dispose ();
117 | _sender = null;
118 | }
119 |
120 | if (_sendToMailIcon != null) {
121 | _sendToMailIcon.Dispose ();
122 | _sendToMailIcon = null;
123 | }
124 |
125 | if (_sendToMailLabel != null) {
126 | _sendToMailLabel.Dispose ();
127 | _sendToMailLabel = null;
128 | }
129 |
130 | if (_separatorImageBottom != null) {
131 | _separatorImageBottom.Dispose ();
132 | _separatorImageBottom = null;
133 | }
134 |
135 | if (_separatorImageTop != null) {
136 | _separatorImageTop.Dispose ();
137 | _separatorImageTop = null;
138 | }
139 |
140 | if (_serviceOwner != null) {
141 | _serviceOwner.Dispose ();
142 | _serviceOwner = null;
143 | }
144 |
145 | if (_subject != null) {
146 | _subject.Dispose ();
147 | _subject = null;
148 | }
149 |
150 | if (_summaryLabel != null) {
151 | _summaryLabel.Dispose ();
152 | _summaryLabel = null;
153 | }
154 |
155 | if (GoToInbox != null) {
156 | GoToInbox.Dispose ();
157 | GoToInbox = null;
158 | }
159 |
160 | if (webview != null) {
161 | webview.Dispose ();
162 | webview = null;
163 | }
164 | }
165 | }
166 | }
167 |
--------------------------------------------------------------------------------
/Core/Models/CookieJar.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using System.Text;
4 |
5 | namespace AltinnApp.Core.Models
6 | {
7 | ///
8 | /// The CookieJar is the container for the cookies Altinn uses
9 | ///
10 | public class CookieJar
11 | {
12 | ///
13 | /// List of cookies in this jar
14 | ///
15 | private readonly List _cookies;
16 |
17 | public string AspxAuthCookie()
18 | {
19 | string ret = string.Empty;
20 | foreach (Cookie c in _cookies)
21 | {
22 | if (c.Name == AppContext.AuthCookieName)
23 | {
24 | ret = c.Name;
25 | }
26 | }
27 | //var c = _cookies.Select(cookie => cookie.Name == AppContext.AuthCookieName) as Cookie;
28 |
29 | return ret;
30 | }
31 |
32 | ///
33 | /// Create a new Cookie Jar
34 | ///
35 | public CookieJar()
36 | {
37 | _cookies = new List();
38 | }
39 |
40 | ///
41 | /// The size is determined to to be the total sum of values of all the cookies in the cookie jar
42 | ///
43 | ///
44 | public int Size()
45 | {
46 | return _cookies.Sum(c => c.Size());
47 | }
48 |
49 | ///
50 | /// Add a new Cookie
51 | ///
52 | ///
53 | public void Add(Cookie cookie)
54 | {
55 | _cookies.Add(cookie);
56 | }
57 |
58 | ///
59 | /// Remove the Cookie with the name cookieName
60 | ///
61 | ///
62 | public void Remove(string cookieName)
63 | {
64 | foreach (Cookie c in _cookies.ToList())
65 | {
66 | if (c.Name == cookieName)
67 | {
68 | _cookies.Remove(c);
69 | }
70 | }
71 | }
72 |
73 | ///
74 | /// Add a collection of cookies
75 | ///
76 | ///
77 | public void AddRange(List cookies)
78 | {
79 | cookies.AddRange(cookies);
80 | }
81 |
82 | ///
83 | /// Update the cookie with the new value newValue
84 | ///
85 | ///
86 | ///
87 | public void Update(Cookie cookie, string newValue)
88 | {
89 | Cookie newCookie = cookie;
90 | newCookie.Value = newValue;
91 | Remove(cookie.Name);
92 | Add(newCookie);
93 | }
94 |
95 | ///
96 | /// Update the cookie with name cookieName and new value newValue
97 | ///
98 | ///
99 | ///
100 | public void Update(string cookieName, string newValue)
101 | {
102 | var newCookie = new Cookie
103 | {
104 | Name = cookieName,
105 | Value = newValue
106 | };
107 | Remove(cookieName);
108 | Add(newCookie);
109 | }
110 |
111 | ///
112 | /// String representation of this cookie jar as a semi-colon separated list on the key=value form
113 | ///
114 | ///
115 | public override string ToString()
116 | {
117 | var str = new StringBuilder();
118 |
119 | foreach (Cookie c in _cookies)
120 | {
121 | string thisCookie = c.Name.ToUpper() + "=" + c.Value + ";";
122 | str.Append(thisCookie);
123 | }
124 |
125 | return str.ToString();
126 | }
127 |
128 | ///
129 | /// Get the IDPorten cookie from the cookie jar
130 | ///
131 | ///
132 | public string IDPortenCookie()
133 | {
134 | string ret = string.Empty;
135 | // ReSharper disable once SuspiciousTypeConversion.Global
136 | var c = _cookies.Select(cookie => cookie.Name == AppContext.IDPortenUrl) as Cookie;
137 | if (c != null)
138 | {
139 | ret = c.Name;
140 | }
141 |
142 | return ret;
143 | }
144 | }
145 | }
--------------------------------------------------------------------------------
/iOS/Components/btprogresshud-1.9/samples/BTProgressHUDSample/BTProgressHUDSample/BTProgressHUDDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | iPhoneSimulator
6 | 10.0.0
7 | 2.0
8 | {E6E84D09-BE15-460D-A317-45248BE1C56F}
9 | {6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
10 | Exe
11 | BTProgressHUDDemo
12 | Resources
13 | BTProgressHUDDemo
14 |
15 |
16 | True
17 | full
18 | False
19 | bin\iPhoneSimulator\Debug
20 | DEBUG;
21 | prompt
22 | 4
23 | False
24 | None
25 | True
26 |
27 |
28 | none
29 | True
30 | bin\iPhoneSimulator\Release
31 | prompt
32 | 4
33 | False
34 | None
35 |
36 |
37 | True
38 | full
39 | False
40 | bin\iPhone\Debug
41 | DEBUG;
42 | prompt
43 | 4
44 | False
45 | True
46 | iPhone Developer
47 |
48 |
49 | none
50 | True
51 | bin\iPhone\Release
52 | prompt
53 | 4
54 | False
55 | iPhone Developer
56 |
57 |
58 | none
59 | True
60 | bin\iPhone\Ad-Hoc
61 | prompt
62 | 4
63 | True
64 | False
65 | Automatic:AdHoc
66 | iPhone Distribution
67 |
68 |
69 | none
70 | True
71 | bin\iPhone\AppStore
72 | prompt
73 | 4
74 | False
75 | iPhone Distribution
76 | Automatic:AppStore
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | ../../../lib\/ios/BTProgressHUD.dll
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/iOS/Util/NativeUrlDelegate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MonoTouch.Foundation;
3 |
4 | namespace AltinnApp.iOS.Util
5 | {
6 | ///
7 | /// Implementation of the native URL delegate, we need to override this to allow selv signed certificates and to monitor the HTTP status codes
8 | ///
9 | internal class NativeUrlDelegate : NSUrlConnectionDelegate
10 | {
11 | ///
12 | /// Success action
13 | ///
14 | private readonly Action _successCallback;
15 |
16 | ///
17 | /// Failure action
18 | ///
19 | private readonly Action _failureCallback;
20 |
21 | ///
22 | /// The data to return
23 | ///
24 | private readonly NSMutableData _data;
25 |
26 | ///
27 | /// HTTP status code
28 | ///
29 | private int _statusCode;
30 |
31 | ///
32 | /// Response object
33 | ///
34 | public NSUrlResponse Resp;
35 |
36 | ///
37 | /// Use this URL delegate if it is neeed to have more control over the connection
38 | ///
39 | ///
40 | ///
41 | public NativeUrlDelegate(Action success, Action failure)
42 | {
43 | _successCallback = success;
44 | _failureCallback = failure;
45 | _data = new NSMutableData();
46 | }
47 |
48 | public override void ReceivedData(NSUrlConnection connection, NSData d)
49 | {
50 | _data.AppendData(d);
51 | }
52 |
53 | public override void ReceivedResponse(NSUrlConnection connection, NSUrlResponse response)
54 | {
55 | var httpResponse = response as NSHttpUrlResponse;
56 | Resp = httpResponse;
57 | if (httpResponse == null)
58 | {
59 | _statusCode = -1;
60 | return;
61 | }
62 |
63 | _statusCode = httpResponse.StatusCode;
64 | }
65 |
66 | public override void FailedWithError(NSUrlConnection connection, NSError error)
67 | {
68 | if (_failureCallback != null)
69 | _failureCallback(error.LocalizedDescription, _statusCode);
70 | }
71 |
72 | public override void FinishedLoading(NSUrlConnection connection)
73 | {
74 | if (_statusCode != 200)
75 | {
76 | _failureCallback(string.Format("Did not receive a 200 HTTP status code, received '{0}'", _statusCode),
77 | _statusCode);
78 | return;
79 | }
80 |
81 | _successCallback(_data, _statusCode);
82 | }
83 |
84 | ///
85 | /// We want to allow self signed certificates in testing for development purposes, it is very important to remove this override for a production product
86 | ///
87 | ///
88 | ///
89 | ///
90 | //public override bool CanAuthenticateAgainstProtectionSpace(NSUrlConnection connection,
91 | // NSUrlProtectionSpace protectionSpace)
92 | //{
93 | // return true;
94 | //}
95 |
96 | ///
97 | /// We want to allow self signed certificates in testing for development purposes, it is very important to remove this override for a production product
98 | ///
99 | ///
100 | ///
101 | //public override void ReceivedAuthenticationChallenge(NSUrlConnection connection,
102 | // NSUrlAuthenticationChallenge challenge)
103 | //{
104 | // if (challenge.ProtectionSpace.AuthenticationMethod == "NSURLAuthenticationMethodServerTrust")
105 | // challenge.Sender.UseCredentials(NSUrlCredential.FromTrust(challenge.ProtectionSpace.ServerSecTrust),
106 | // challenge);
107 |
108 | // if (challenge.PreviousFailureCount > 0)
109 | // {
110 | // challenge.Sender.CancelAuthenticationChallenge(challenge);
111 | // Logger.Logg("Authentication failure");
112 | // return;
113 | // }
114 |
115 | // if (challenge.ProtectionSpace.AuthenticationMethod == "NSURLAuthenticationMethodServerTrust")
116 | // challenge.Sender.UseCredentials(NSUrlCredential.FromTrust(challenge.ProtectionSpace.ServerSecTrust),
117 | // challenge);
118 | //}
119 | }
120 | }
--------------------------------------------------------------------------------
/Core/Models/Message.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace AltinnApp.Core.Models
4 | {
5 | ///
6 | /// These are the models used to de-serialize the JSON objects comming from the API
7 | ///
8 | public class Rootobject
9 | {
10 | ///
11 | /// Gets or sets the array of messages
12 | ///
13 | public Message[] Messages { get; set; }
14 | }
15 |
16 | ///
17 | /// The Message contains all the fields which are common to the types FormTask and Correspondence, to get the specific
18 | /// fields you have to use the "self" link on the message
19 | ///
20 | public class Message
21 | {
22 | public string SavedFileName;
23 | public bool IsDownloaded { get; set; }
24 |
25 | public string AdjustedDate { get; set; }
26 |
27 |
28 | ///
29 | /// Gets or sets the ID of this message
30 | ///
31 | public string MessageId { get; set; }
32 |
33 | ///
34 | /// Gets or sets the subject of this message
35 | ///
36 | public string Subject { get; set; }
37 |
38 | ///
39 | /// Gets or sets the status of this message
40 | ///
41 | public string Status { get; set; }
42 |
43 | ///
44 | /// Gets or sets the last date of change for this message
45 | ///
46 | public DateTime LastChangedDateTime { get; set; }
47 |
48 | ///
49 | /// Gets or sets the entity who changes this message last
50 | ///
51 | public string LastChangedBy { get; set; }
52 |
53 | ///
54 | /// Gets or sets the Service Owner
55 | ///
56 | public string ServiceOwner { get; set; }
57 |
58 | ///
59 | /// Gets or sets the Type
60 | ///
61 | public string Type { get; set; }
62 |
63 | ///
64 | /// Gets or sets the ServiceCode
65 | ///
66 | public string ServiceCode { get; set; }
67 |
68 | ///
69 | /// Gets or sets the ServiceEdition
70 | ///
71 | public int ServiceEdition { get; set; }
72 |
73 | ///
74 | /// Gets or sets the list of links for this message
75 | ///
76 | [Newtonsoft.Json.JsonProperty(PropertyName = "_links")]
77 | public _Links Links { get; set; }
78 |
79 | ///
80 | /// Gets or sets the summary of the Correspondence, specific for Correspondences
81 | ///
82 | public string Summary { get; set; }
83 |
84 | ///
85 | /// Gets or sets the body of the Correspondence in HTML, specific for Correspondences
86 | ///
87 | public string Body { get; set; }
88 | }
89 |
90 | ///
91 | /// The REST links related to a message
92 | ///
93 | // ReSharper disable once InconsistentNaming
94 | public class _Links
95 | {
96 | ///
97 | /// Gets or sets the Self
98 | ///
99 | public Self Self { get; set; }
100 |
101 | ///
102 | /// Gets or sets the Print
103 | ///
104 | public Print Print { get; set; }
105 |
106 | ///
107 | /// Gets or sets the array of attachments
108 | ///
109 | public Attachment[] Attachment { get; set; }
110 | }
111 |
112 | ///
113 | /// This message
114 | ///
115 | public class Self
116 | {
117 | ///
118 | /// Gets or sets the Href
119 | ///
120 | public string Href { get; set; }
121 | }
122 |
123 | ///
124 | /// The print view of a FormTask, specific for FormTasks
125 | ///
126 | public class Print
127 | {
128 | ///
129 | /// Gets or sets the URI to the print view
130 | ///
131 | public string Href { get; set; }
132 |
133 | ///
134 | /// Gets or sets the MIME type
135 | ///
136 | [Newtonsoft.Json.JsonProperty(PropertyName = "mime-type")]
137 | public string Mimetype { get; set; }
138 | }
139 |
140 | ///
141 | /// The Attachment of a Correspondence, specific for Correspondences
142 | ///
143 | public class Attachment
144 | {
145 | public string Mimetype { get; set; }
146 |
147 | ///
148 | /// Gets or sets the URI to the Attachment
149 | ///
150 | public string Href { get; set; }
151 |
152 | public string FileEnding { get; set; }
153 |
154 | ///
155 | /// Gets or sets the name of the Attachment
156 | ///
157 | public string Name { get; set; }
158 |
159 | ///
160 | /// Gets or sets a value indicating whether or not the Attachment is encrypted, if it is encrypted any download of the file will be corrupt
161 | ///
162 | public bool Encrypted { get; set; }
163 | }
164 | }
--------------------------------------------------------------------------------
/Core/AltinnApp.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 10.0
6 | Debug
7 | AnyCPU
8 | {4B51EB49-EC2D-4731-9E56-998F6640CEBA}
9 | Library
10 | Properties
11 | AltinnApp.Core
12 | AltinnApp.Core
13 | v4.5
14 | Profile49
15 | 512
16 | {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
17 | 1
18 | SAK
19 | SAK
20 | SAK
21 | SAK
22 | false
23 | false
24 | ..\iOS-1.0.7\
25 |
26 |
27 |
28 | true
29 | full
30 | false
31 | bin\Debug\
32 | DEBUG;TRACE
33 | prompt
34 | 4
35 | false
36 |
37 |
38 | pdbonly
39 | true
40 | bin\Release\
41 | TRACE
42 | prompt
43 | 4
44 |
45 |
48 |
49 |
50 |
51 | Designer
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | False
80 | ..\iOS-1.0.7\packages\Newtonsoft.Json.6.0.3\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll
81 |
82 |
83 | ..\iOS-1.0.7\packages\Microsoft.Net.Http.2.2.22\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll
84 |
85 |
86 | ..\iOS-1.0.7\packages\Microsoft.Net.Http.2.2.22\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll
87 |
88 |
89 | ..\iOS-1.0.7\packages\Microsoft.Net.Http.2.2.22\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
105 |
112 |
--------------------------------------------------------------------------------
/iOS/FormViewController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using AltinnApp.Core.Models;
4 | using AltinnApp.Core.Util;
5 | using AltinnApp.iOS.CorePlatform;
6 | using BigTed;
7 | using MonoTouch.Foundation;
8 | using MonoTouch.UIKit;
9 |
10 | namespace AltinnApp.iOS
11 | {
12 | ///
13 | /// The class for controlling the view of formTasks
14 | ///
15 | public partial class FormViewController : UIViewController
16 | {
17 | //private SI _si;
18 | private Translate _trans;
19 | private Constants.MMBType _type;
20 |
21 | public Constants.MMBType Type
22 | {
23 | get { return _type; }
24 | set { _type = value; }
25 | }
26 |
27 | ///
28 | /// Default constructor
29 | ///
30 | ///
31 | public FormViewController(IntPtr handle)
32 | : base(handle)
33 | {
34 | }
35 |
36 | public Message CurrentMessage { get; set; }
37 |
38 | public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
39 | {
40 | base.PrepareForSegue(segue, sender);
41 | var view = (AttachmentController) segue.DestinationViewController;
42 | view.SelectedMessage = CurrentMessage;
43 | }
44 |
45 | public override void ViewDidAppear(bool animated)
46 | {
47 | base.ViewDidAppear(animated);
48 | BTProgressHUD.Dismiss();
49 | }
50 |
51 | public override void ViewDidLoad()
52 | {
53 | base.ViewDidLoad();
54 | BTProgressHUD.Show();
55 |
56 | ConfigureView();
57 | _trans = new Translate();
58 |
59 | Localize();
60 | }
61 |
62 | private void Localize()
63 | {
64 | if (_type == Constants.MMBType.Archive)
65 | {
66 | _goToInbox.Text = _trans.GetString("MessageboxController_ArchiveHeader");
67 | if (CurrentMessage.MessageId.ToLower().StartsWith("c"))
68 | {
69 | _printLabel.Text = _trans.GetString("Message_ArchivedAltinn1");
70 | _printIcon.Enabled = false;
71 | _printLabel.TextColor = UIColor.FromRGB (181, 181, 181);
72 | }
73 | else
74 | {
75 | _printLabel.Text = _trans.GetString("Message_Archived");
76 | }
77 | }
78 | else if (_type == Constants.MMBType.Messagebox)
79 | {
80 | _goToInbox.Text = _trans.GetString("MessageboxController_InboxHeader");
81 | _printLabel.Text = _trans.GetString("Message_Print");
82 | }
83 | else
84 | {
85 | _goToInbox.Text = string.Empty;
86 | }
87 |
88 |
89 | _header.Text = _trans.GetString("FormController_Header");
90 | _recipientLabel.Text = _trans.GetString("Message_Recipient");
91 | _lastChangedDateLabel.Text = _trans.GetString("Message_LastChanged");
92 | _infoBox.Text = _trans.GetString("Message_Infobox");
93 | _lastChangedByLabel.Text = _trans.GetString("Message_LastChangedBy");
94 | }
95 |
96 | // ReSharper disable once UnusedMember.Local
97 | // ReSharper disable once UnusedParameter.Local
98 | partial void GoBack(NSObject sender)
99 | {
100 | NavigationController.PopViewControllerAnimated(true);
101 | }
102 |
103 | // ReSharper disable once UnusedMember.Local
104 | // ReSharper disable once UnusedParameter.Local
105 | partial void HandleSwipeRight(NSObject sender)
106 | {
107 | GoBack(null);
108 | }
109 |
110 | public override bool ShouldAutorotate()
111 | {
112 | return false;
113 | }
114 |
115 | // ReSharper disable once UnusedMember.Local
116 | // ReSharper disable once UnusedParameter.Local
117 | partial void OpenPrint(NSObject sender)
118 | {
119 | }
120 |
121 | private async void ConfigureView()
122 | {
123 | try
124 | {
125 | //var si = new PlattformService();
126 | if (IsViewLoaded && CurrentMessage != null)
127 | {
128 | //Retrieve the full message
129 |
130 | AddPadding();
131 |
132 | if (!CurrentMessage.IsDownloaded)
133 | {
134 | CurrentMessage = await PlattformService.Service.GetMessage(CurrentMessage);
135 | }
136 |
137 | _subject.Text = CurrentMessage.Subject;
138 | _lastChangedDate.Text += CurrentMessage.LastChangedDateTime.ToString("dd.MM.yyyy hh:mm",
139 | CultureInfo.InvariantCulture);
140 | _lastChangedBy.Text += CurrentMessage.LastChangedBy;
141 | //we can either hide the controls or set then enabled = false and use a separate icon for that state (can be set in the Storyboard)
142 |
143 | //The rest depend on if we have a print view of the FormTask
144 | if (CurrentMessage.Links != null && CurrentMessage.Links.Print != null &&
145 | CurrentMessage.Links.Print.Href != null)
146 | {
147 | //If no print view exist hide the controls
148 | _printIcon.Hidden = false;
149 | _printLabel.Hidden = false;
150 | }
151 | else
152 | {
153 | _printIcon.Hidden = true;
154 | _printLabel.Hidden = true;
155 | }
156 |
157 |
158 | _recipient.Text = CurrentMessage.ServiceOwner ?? CurrentMessage.ServiceOwner;
159 | }
160 | }
161 | catch (AppException app)
162 | {
163 | Util.Util.HandleAppException(app, this);
164 | }
165 | catch (Exception ex)
166 | {
167 | Logger.Logg("General error occured when getting the message: " + ex);
168 | Util.Util.ShowAlert(ErrorMessages.GeneralError);
169 | }
170 | }
171 |
172 | private void AddPadding()
173 | {
174 | //If we have English, add some more spaces to the label
175 | _lastChangedDate.Text = string.Empty;
176 |
177 | _lastChangedBy.Text = string.Empty;
178 | if (AppContext.CurrentLanguage == "1033") {
179 | _lastChangedDate.Text = " ";
180 |
181 | _lastChangedBy.Text = " ";
182 | } else if (AppContext.CurrentLanguage == "2068") {
183 |
184 |
185 | } else if (AppContext.CurrentLanguage == "1044") {
186 | _lastChangedDate.Text = " ";
187 | }
188 | }
189 | }
190 | }
--------------------------------------------------------------------------------
/iOS/FlyoutController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using BigTed;
3 | using MonoTouch.Foundation;
4 | using MonoTouch.UIKit;
5 | using SWRevealViewControllerBinding;
6 | using AltinnApp.Core.Models;
7 | using AltinnApp.Core.Util;
8 |
9 | namespace AltinnApp.iOS
10 | {
11 | public partial class FlyoutController : UIViewController
12 | {
13 | private CorePlatform.Translate _trans;
14 |
15 | public FlyoutController(IntPtr handle)
16 | : base(handle)
17 | {
18 | }
19 |
20 | public override void ViewDidLoad()
21 | {
22 | base.ViewDidLoad();
23 | //var tableView = _tableView;
24 | if (_tableView != null)
25 | {
26 | _tableView.Source = new FlyoutTablesource();
27 | _tableView.BackgroundColor = UIColor.FromRGB (108, 108, 108);
28 | this.View.BackgroundColor = UIColor.FromRGB (108, 108, 108);
29 | }
30 |
31 | if (Session.Organizations != null && Session.Organizations.Count == 1)
32 | {
33 | _actorLabel.Hidden = true;
34 | _actorForwardIcon.Hidden = true;
35 | }
36 | _trans = new CorePlatform.Translate();
37 | }
38 |
39 | private void Localize()
40 | {
41 | //If we have English, add some more spaces to the label
42 | if (AppContext.CurrentLanguage == "1033")
43 | {
44 | _actorLabel.SetTitle(_trans.GetString("FlyoutController_Actor"), UIControlState.Normal);
45 | _actorLabel.SetTitle(_trans.GetString("FlyoutController_Actor"), UIControlState.Selected);
46 | }
47 | else
48 | {
49 | _actorLabel.SetTitle(_trans.GetString("FlyoutController_Actor"), UIControlState.Normal);
50 | _actorLabel.SetTitle(_trans.GetString("FlyoutController_Actor"), UIControlState.Selected);
51 | }
52 |
53 |
54 | _logoutButton.SetTitle(_trans.GetString("FlyoutController_LogoutButton"), UIControlState.Normal);
55 | _logoutButton.SetTitle(_trans.GetString("FlyoutController_LogoutButton"), UIControlState.Selected);
56 | }
57 |
58 | public override void ViewWillAppear(bool animated)
59 | {
60 | base.ViewWillAppear(animated);
61 | //_tableView.UpdateConstraints ();
62 | }
63 |
64 | public override void ViewDidLayoutSubviews()
65 | {
66 | base.ViewDidLayoutSubviews();
67 | }
68 |
69 | public override void ViewWillDisappear(bool animated)
70 | {
71 | base.ViewWillDisappear(animated);
72 | }
73 |
74 | public override void WillMoveToParentViewController(UIViewController parent)
75 | {
76 | base.WillMoveToParentViewController(parent);
77 | }
78 |
79 | public override void ViewDidAppear(bool animated)
80 | {
81 | base.ViewDidAppear(animated);
82 |
83 | BTProgressHUD.Dismiss();
84 | if (Session.Organizations != null && Session.Organizations.Count == 1)
85 | {
86 | _actorLabel.Hidden = true;
87 | _actorForwardIcon.Hidden = true;
88 | }
89 |
90 | if (Session.SelectedOrg != null && Session.Profile != null)
91 | {
92 | if (Session.SelectedOrg.Name == Session.Profile.Name)
93 | {
94 | _nameLabel.Text = Session.Profile.FirstName;
95 | _lastNameLabel.Text = Session.Profile.LastName;
96 | }
97 | else
98 | {
99 | _nameLabel.Text = Session.SelectedOrg.Name;
100 | _lastNameLabel.Text = Session.SelectedOrg.OrganizationNumber;
101 | }
102 | }
103 |
104 |
105 | Localize();
106 | _tableView.ReloadData();
107 | }
108 |
109 | // ReSharper disable once UnusedMember.Local
110 | // ReSharper disable once UnusedParameter.Local
111 | partial void _logout(NSObject sender)
112 | {
113 | //Clear all the cookies and user data
114 | Util.Util.Logout();
115 |
116 | //Logout method 2 with external browser (required for BankID)
117 | if (AppContext.LoginMethod == 2)
118 | {
119 | var url =
120 | new NSUrl(AppContext.AppStopUrl + "?logout=true&appUrl=" + AppContext.AppUrlSchema + "&appKey=" +
121 | AppContext.ApiKey);
122 | UIApplication.SharedApplication.OpenUrl(url);
123 | }
124 | else if (AppContext.LoginMethod != 1)
125 | {
126 | //Logout method 1 with the internal browser
127 | //this.RevealViewController ().PerformSegue("Logout", this);
128 | DismissViewController(true, null);
129 | //this.RevealViewController ().NavigationController.PopToViewController(Util.Util.Root, true);
130 | }
131 | }
132 |
133 | public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
134 | {
135 | base.PrepareForSegue(segue, sender);
136 | var segueReveal = segue as SWRevealViewControllerSegue;
137 | if (segueReveal == null)
138 | {
139 | return;
140 | }
141 | var destinationController = segueReveal.DestinationViewController;
142 | if (destinationController != null && sender is UITableViewCell)
143 | {
144 | var senderCell = sender as UITableViewCell;
145 | if (senderCell.ReuseIdentifier == "Inbox")
146 | {
147 | //destinationController.LabelContent = "2";
148 | //destinationController.ViewColor = UIColor.Green;
149 | ((MessageboxController) destinationController).MMBType = Constants.MMBType.Messagebox;
150 | }
151 | else if (senderCell.ReuseIdentifier == "Archive")
152 | {
153 | ((MessageboxController) destinationController).MMBType = Constants.MMBType.Archive;
154 | }
155 | else if (senderCell.ReuseIdentifier == "Settings")
156 | {
157 | }
158 | else if (senderCell.ReuseIdentifier == "Contact")
159 | {
160 | }
161 | else if (senderCell.ReuseIdentifier == "Feedback")
162 | {
163 | }
164 | }
165 | //this.RevealViewController().SetFrontViewController(segueReveal.DestinationViewController, true);
166 | // this.RevealViewController().SetFrontViewController(segueReveal.DestinationViewController, false);
167 | // this.RevealViewController().SetFrontViewPosition(FrontViewPosition.LeftSide, true);
168 | this.RevealViewController().SetFrontViewController(segueReveal.DestinationViewController, false);
169 | this.RevealViewController().SetFrontViewPosition(FrontViewPosition.LeftSideMostRemoved, true);
170 | }
171 | }
172 | }
--------------------------------------------------------------------------------
/Core/Settings.StyleCop:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | preprocessor, pre-processor
5 | shortlived, short-lived
6 |
7 |
8 | altinn
9 | BankID
10 | brreg
11 | Buypass
12 | Commfides
13 | formset
14 | ID-Porten
15 | participant
16 | reportee
17 | ssn
18 | subform
19 | subforms
20 | xfd
21 |
22 | 10000
23 |
24 |
25 |
26 |
27 |
28 |
29 | False
30 |
31 |
32 |
33 |
34 | False
35 |
36 |
37 |
38 |
39 | False
40 |
41 |
42 |
43 |
44 | False
45 |
46 |
47 |
48 |
49 | False
50 |
51 |
52 |
53 |
54 | False
55 |
56 |
57 |
58 |
59 | False
60 |
61 |
62 |
63 |
64 | False
65 |
66 |
67 |
68 |
69 | False
70 |
71 |
72 |
73 |
74 | False
75 |
76 |
77 |
78 |
79 | False
80 |
81 |
82 |
83 |
84 | False
85 |
86 |
87 |
88 |
89 | False
90 |
91 |
92 |
93 |
94 | True
95 |
96 |
97 |
98 |
99 |
100 |
101 | False
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 | False
112 |
113 |
114 |
115 |
116 | False
117 |
118 |
119 |
120 |
121 |
122 | a1
123 | at
124 | d
125 | db
126 | dr
127 | ds
128 | dt
129 | er
130 | f
131 | fs
132 | go
133 | ip
134 | li
135 | ns
136 | or
137 | pi
138 | pv
139 | sa
140 | sb
141 | se
142 | si
143 | so
144 | sp
145 | wf
146 | ws
147 | x
148 | y
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 | False
157 |
158 |
159 |
160 |
161 | False
162 |
163 |
164 |
165 |
166 | False
167 |
168 |
169 |
170 |
171 | False
172 |
173 |
174 |
175 |
176 | False
177 |
178 |
179 |
180 |
181 | False
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 | False
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 | False
202 |
203 |
204 |
205 |
206 |
207 |
208 |
--------------------------------------------------------------------------------
/iOS/Settings.StyleCop:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | preprocessor, pre-processor
5 | shortlived, short-lived
6 |
7 |
8 | altinn
9 | BankID
10 | brreg
11 | Buypass
12 | Commfides
13 | formset
14 | ID-Porten
15 | participant
16 | reportee
17 | ssn
18 | subform
19 | subforms
20 | xfd
21 |
22 | 10000
23 |
24 |
25 |
26 |
27 |
28 |
29 | False
30 |
31 |
32 |
33 |
34 | False
35 |
36 |
37 |
38 |
39 | False
40 |
41 |
42 |
43 |
44 | False
45 |
46 |
47 |
48 |
49 | False
50 |
51 |
52 |
53 |
54 | False
55 |
56 |
57 |
58 |
59 | False
60 |
61 |
62 |
63 |
64 | False
65 |
66 |
67 |
68 |
69 | False
70 |
71 |
72 |
73 |
74 | False
75 |
76 |
77 |
78 |
79 | False
80 |
81 |
82 |
83 |
84 | False
85 |
86 |
87 |
88 |
89 | False
90 |
91 |
92 |
93 |
94 | True
95 |
96 |
97 |
98 |
99 |
100 |
101 | False
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 | False
112 |
113 |
114 |
115 |
116 | False
117 |
118 |
119 |
120 |
121 |
122 | a1
123 | at
124 | d
125 | db
126 | dr
127 | ds
128 | dt
129 | er
130 | f
131 | fs
132 | go
133 | ip
134 | li
135 | ns
136 | or
137 | pi
138 | pv
139 | sa
140 | sb
141 | se
142 | si
143 | so
144 | sp
145 | wf
146 | ws
147 | x
148 | y
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 | False
157 |
158 |
159 |
160 |
161 | False
162 |
163 |
164 |
165 |
166 | False
167 |
168 |
169 |
170 |
171 | False
172 |
173 |
174 |
175 |
176 | False
177 |
178 |
179 |
180 |
181 | False
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 | False
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 | False
202 |
203 |
204 |
205 |
206 |
207 |
208 |
--------------------------------------------------------------------------------
/iOS/LoginController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using AltinnApp.Core.Models;
3 | using BigTed;
4 | using MonoTouch.Foundation;
5 | using MonoTouch.UIKit;
6 | using SWRevealViewControllerBinding;
7 |
8 | namespace AltinnApp.iOS
9 | {
10 | ///
11 | /// Class for displaying the first info screen and decide login
12 | ///
13 | public partial class LoginController : UIViewController
14 | {
15 | private LoginWebController _loginIdPortenWebController;
16 | private CorePlatform.Translate _trans;
17 |
18 | ///
19 | /// Default constructor
20 | ///
21 | ///
22 | public LoginController(IntPtr handle)
23 | : base(handle)
24 | {
25 | }
26 |
27 | public override void ViewDidLoad()
28 | {
29 | base.ViewDidLoad();
30 | UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, false);
31 | _trans = new CorePlatform.Translate();
32 |
33 | _loginIdPortenWebController =
34 | Storyboard.InstantiateViewController("LoginWebController") as LoginWebController;
35 |
36 |
37 | OpenLanguage.TouchUpInside += (sender, e) =>
38 | {
39 | var prompt = new UIAlertView(string.Empty, _trans.GetString("Popup_SelectLanguage"), null,
40 | _trans.GetString("Misc_Cancel"),
41 | new[]
42 | {
43 | _trans.GetString("Misc_Lang_Bokmaal"), _trans.GetString("Misc_Lang_Nynorsk"),
44 | _trans.GetString("Misc_Lang_English")
45 | })
46 | {
47 | AlertViewStyle = UIAlertViewStyle.Default
48 | };
49 |
50 |
51 | prompt.Clicked += (s, b) =>
52 | {
53 | Localize();
54 | if (b.ButtonIndex == 0)
55 | {
56 | }
57 | else if (b.ButtonIndex == 1)
58 | {
59 | AppContext.CurrentCulture = "nb-NO";
60 | AppContext.CurrentLanguage = "1044";
61 | }
62 | else if (b.ButtonIndex == 2)
63 | {
64 | AppContext.CurrentCulture = "nn-NO";
65 | AppContext.CurrentLanguage = "2068";
66 | }
67 | else if (b.ButtonIndex == 3)
68 | {
69 | AppContext.CurrentCulture = "en";
70 | AppContext.CurrentLanguage = "1033";
71 | }
72 | Util.Util.SetLanguage();
73 | Localize();
74 | };
75 | prompt.Show();
76 | };
77 |
78 | //Add this as an observer of the Settings
79 | NSNotificationCenter.DefaultCenter.AddObserver(new NSString("NSUserDefaultsDidChangeNotification"),
80 | // ReSharper disable once RedundantLambdaParameterType
81 | (NSNotification obj) =>
82 | {
83 | NSUserDefaults.StandardUserDefaults.Synchronize();
84 | LoadSettings();
85 | });
86 |
87 | Util.Util.Root = this;
88 |
89 | AppContext.hasLaunched = NSUserDefaults.StandardUserDefaults.BoolForKey("hasLaunched");
90 |
91 | if (!AppContext.hasLaunched)
92 | {
93 | NSUserDefaults.StandardUserDefaults.SetBool(true, "hasLaunched");
94 | }
95 | }
96 |
97 | private void Localize()
98 | {
99 | _IntroText.Text = _trans.GetString("LoginController_Infobox");
100 | _LoginButton.SetTitle(_trans.GetString("LoginController_Loginbutton"), UIControlState.Normal);
101 | _LoginButton.SetTitle(_trans.GetString("LoginController_Loginbutton"), UIControlState.Highlighted);
102 | OpenLanguage.SetTitle(" " + _trans.GetString("LoginController_CurrentLanguage"), UIControlState.Normal);
103 | OpenLanguage.SetTitle(" " + _trans.GetString("LoginController_CurrentLanguage"), UIControlState.Highlighted);
104 | }
105 |
106 | ///
107 | /// The ViewWillAppear runs everytime the view refreshes (ViewDidLoad runs once)
108 | ///
109 | /// If set to true animated.
110 | public override void ViewWillAppear(bool animated)
111 | {
112 | LoadSettings();
113 | Localize();
114 | BTProgressHUD.Dismiss();
115 | }
116 |
117 | //Loads the settings
118 | private void LoadSettings()
119 | {
120 | //Load the settings, mainly which environment to use, by default Production
121 | AppContext.SelectedEnvironment = AppContext.EnvironmentType.PROD;
122 |
123 | //Try to get the selected environment from the settings
124 | Enum.TryParse(NSUserDefaults.StandardUserDefaults.StringForKey("Environment"), true,
125 | out AppContext.SelectedEnvironment);
126 |
127 | AppContext.SetDomain(AppContext.SelectedEnvironment);
128 | string selection = NSUserDefaults.StandardUserDefaults.StringForKey("LoginUseExternalBrowser");
129 | AppContext.UseExternalBrowser = selection == "1";
130 | }
131 |
132 | ///
133 | /// Process the click of the "login" button
134 | ///
135 | /// Sender.
136 | // ReSharper disable once UnusedMember.Local
137 | // ReSharper disable once UnusedParameter.Local
138 | partial void Login(NSObject sender)
139 | {
140 | //Check if the user is logged in
141 | if (Session.LoggedIn)
142 | //if (true)
143 | {
144 | //if (true)
145 | var flyoutController = Storyboard.InstantiateViewController("FlyoutRoot") as SWRevealViewController;
146 | if (flyoutController != null)
147 | {
148 | NavigationController.PushViewController(flyoutController, true);
149 | }
150 | }
151 | else
152 | {
153 | //Otherwise show the loginscreen
154 | //The environments where the new BankID solution is not deployed we use with integrated webview
155 | //if (!AppContext.UseExternalBrowser)
156 | if (false)
157 | {
158 | //As long as AppStart is in a environments we use it, at least until BankID 2.0 i live
159 | BTProgressHUD.Show();
160 | NavigationController.PushViewController(_loginIdPortenWebController, true);
161 | AppContext.LoginMethod = 1; //Integrated browser method
162 | }
163 | //else if (AppContext.UseExternalBrowser)
164 | else if (true)
165 | {
166 | //AppContext.FirstTimeStarting = true;
167 |
168 | if (!AppContext.hasLaunched)
169 | {
170 | //The first time we start we show the infoscreen
171 | var infoScreenController =
172 | Storyboard.InstantiateViewController("InfoscreenController") as UIViewController;
173 | if (infoScreenController != null)
174 | {
175 | NavigationController.PresentViewController(infoScreenController, true, null);
176 | }
177 | }
178 | else
179 | {
180 | //For the environments with the new BankID solution we use the new BankID solution
181 | //which is to use AppStart.aspx as a proxy for the login, we need to send along this app's URL schema and the APIKey
182 | var url =
183 | new NSUrl(AppContext.AppStartUrl + "?ApiDomain=" + AppContext.AppUrlSchema + "&ApiKey=" +
184 | AppContext.ApiKey);
185 | UIApplication.SharedApplication.OpenUrl(url);
186 | AppContext.LoginMethod = 2; //External browser method
187 | // BTProgressHUD.Show();
188 | }
189 | }
190 | }
191 | }
192 | }
193 | }
--------------------------------------------------------------------------------
/iOS/ReporteeController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using AltinnApp.Core.Models;
3 | using AltinnApp.Core.Util;
4 | using AltinnApp.iOS.CorePlatform;
5 | using BigTed;
6 | using MonoTouch.Foundation;
7 | using MonoTouch.UIKit;
8 | using SWRevealViewControllerBinding;
9 |
10 | namespace AltinnApp.iOS
11 | {
12 | ///
13 | /// This class controls the display and selection of reportees
14 | ///
15 | public partial class ReporteeController : UIViewController
16 | {
17 | private Translate _trans;
18 | private bool _once = true;
19 | ///
20 | /// Default constructor
21 | ///
22 | ///
23 | public ReporteeController(IntPtr handle)
24 | : base(handle)
25 | {
26 | //_service = new PlattformService();
27 | }
28 |
29 | ///
30 | /// Creates a new ReporteeController
31 | ///
32 | public ReporteeController()
33 | {
34 | }
35 |
36 |
37 | private void Localize()
38 | {
39 | _header.Text = _trans.GetString("ReporteeController_Header");
40 | _innboxLabel.SetTitle(_trans.GetString("MessageboxController_InboxHeader"), UIControlState.Normal);
41 | }
42 |
43 | public override void ViewDidLoad()
44 | {
45 | base.ViewDidLoad();
46 |
47 | tableView.WeakDataSource = tableView.WeakDelegate = this;
48 |
49 | _goBack.TouchUpInside += (sender, e) => this.RevealViewController().RevealToggleAnimated(true);
50 |
51 | _innboxLabel.TouchUpInside += (sender, e) =>
52 | {
53 | try
54 | {
55 | var controller =
56 | Storyboard.InstantiateViewController("MessageboxIdentifier") as MessageboxController;
57 | if (controller != null)
58 | {
59 | controller.MMBType = Constants.MMBType.Messagebox;
60 | this.RevealViewController().SetFrontViewController(controller, true);
61 | }
62 | }
63 | catch (Exception ex)
64 | {
65 | Logger.Logg(ex);
66 | }
67 | };
68 |
69 | _trans = new Translate();
70 | View.AddGestureRecognizer(this.RevealViewController().PanGestureRecognizer);
71 | //Make sure the fields are blanked out
72 | _searchField.Placeholder = _trans.GetString("Misc_SearchboxPlaceholder");
73 | _searchField.TextChanged += SearchTextChanged;
74 | _searchField.OnEditingStopped += SearchStopped;
75 | _searchField.OnEditingStarted += SearchStarted;
76 | _searchField.CancelButtonClicked += CancelButtonClicked;
77 | _searchField.SearchButtonClicked += SearchButtonClicked;
78 |
79 | Localize();
80 | }
81 |
82 |
83 | ///
84 | /// Triggered each time the text in the search filed changes
85 | ///
86 | ///
87 | ///
88 | private void SearchTextChanged(object sender, UISearchBarTextChangedEventArgs e)
89 | {
90 | Session.SearchActor(e.SearchText);
91 | tableView.ReloadData();
92 | }
93 |
94 |
95 | private async void SearchButtonClicked(object sender, EventArgs e)
96 | {
97 | string searchValue = _searchField.Text;
98 | _searchField.ResignFirstResponder();
99 |
100 | BTProgressHUD.Show();
101 | Session.Organizations = await PlattformService.Service.SearchActorRemote(searchValue);
102 |
103 | tableView.ReloadData();
104 | BTProgressHUD.Dismiss();
105 | }
106 |
107 | private void CancelButtonClicked(object sender, EventArgs e)
108 | {
109 | _searchField.Text = string.Empty;
110 | Session.Organizations = Session.UnfilteredOrganizations;
111 | }
112 |
113 | private void SearchStarted(object sender, EventArgs e)
114 | {
115 | }
116 |
117 | private void SearchStopped(object sender, EventArgs e)
118 | {
119 | }
120 |
121 | [Export("scrollViewDidScroll:")]
122 | public async void Scrolled2(UIScrollView scrollView)
123 | {
124 | try
125 | {
126 | if (Session.Organizations.Count >= 50 && _once)
127 | {
128 | if ((tableView.ContentOffset.Y) >= (tableView.ContentSize.Height - tableView.Bounds.Size.Height + 40))
129 | {
130 | _once = false;
131 | if ((Session.Organizations.Count % 50) == 0)
132 | {
133 | //If we have a messagebox size modulo 50 = 0 then we know we reached the max size for one call and have to check
134 | //if there are any more messages with a skip starting at the last element in the messagebox
135 | var mess = await PlattformService.Service.PopulateOrganizations(Session.Organizations.Count);
136 | }
137 | }
138 | }
139 | }
140 | catch (Exception e)
141 | {
142 | Logger.Logg("Failed to retrieve more than 50 organizations");
143 | }
144 | }
145 |
146 | [Export("tableView:numberOfRowsInSection:")]
147 | public int RowsInSection(UITableView tableview, int section)
148 | {
149 | if (Session.Organizations != null)
150 | {
151 | return Session.Organizations.Count;
152 | }
153 | return 0;
154 | }
155 |
156 | [Export("tableView:cellForRowAtIndexPath:")]
157 | // ReSharper disable once ParameterHidesMember
158 | public UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
159 | {
160 | const string cellName = "aCell";
161 | var cell = tableView.DequeueReusableCell(cellName) ??
162 | new UITableViewCell(UITableViewCellStyle.Subtitle, cellName);
163 | if (Session.Organizations != null)
164 | {
165 | Organization org = Session.Organizations[indexPath.Row];
166 | if (org.OrganizationNumber == "my")
167 | {
168 | cell.TextLabel.Text = org.Name;
169 | }
170 | else
171 | {
172 | cell.TextLabel.Text = org.OrganizationNumber + " - " + org.Name;
173 | }
174 |
175 |
176 | if (org.OrganizationNumber == Session.SelectedOrg.OrganizationNumber)
177 | {
178 | try
179 | {
180 | cell.AccessoryView = new UIImageView(UIImage.FromBundle("Infoscreen-Grey_checked.png"));
181 | }
182 | catch (Exception ex)
183 | {
184 | Logger.Logg("Failed to set cell background color" + ex);
185 | }
186 | }
187 | else
188 | {
189 | cell.AccessoryView = null;
190 | }
191 | }
192 |
193 | var backgroundView = new UIView(cell.Frame) {BackgroundColor = UIColor.FromRGB(229, 225, 156)};
194 | cell.SelectedBackgroundView = backgroundView;
195 |
196 | return cell;
197 | }
198 |
199 | [Export("tableView:didSelectRowAtIndexPath:")]
200 | // ReSharper disable once ParameterHidesMember
201 | public void RowSelected(UITableView tableView, NSIndexPath indexPath)
202 | {
203 | //When a reportee is selected, make it so in the AppContext
204 | //null out the filter when we change reportee
205 | if (Session.Organizations != null)
206 | {
207 | var selected = Session.Organizations[indexPath.Row];
208 |
209 | Session.SelectedOrg = selected;
210 | }
211 | tableView.ReloadData();
212 | }
213 |
214 | // ReSharper disable once UnusedMember.Local
215 | // ReSharper disable once UnusedParameter.Local
216 | partial void GoBack(NSObject sender)
217 | {
218 | //NavigationController.PopViewControllerAnimated(true);
219 | }
220 | }
221 | }
--------------------------------------------------------------------------------
/iOS/Util/Reachability.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using MonoTouch.CoreFoundation;
4 | using MonoTouch.SystemConfiguration;
5 |
6 | namespace AltinnApp.iOS.Util
7 | {
8 | public enum NetworkStatus
9 | {
10 | NotReachable,
11 | ReachableViaCarrierDataNetwork,
12 | ReachableViaWiFiNetwork
13 | }
14 |
15 | ///
16 | /// Class that implements many usefull methods to check for network availability. Copy/paste from Xamarin.
17 | ///
18 | public class Reachability
19 | {
20 | public NetworkStatus Status { get; private set; }
21 |
22 | public bool ConnectionRequired { get; private set; }
23 |
24 | private Reachability()
25 | {
26 | }
27 |
28 | private static bool IsReachableWithoutRequiringConnection(NetworkReachabilityFlags flags)
29 | {
30 | // Is it reachable with the current network configuration?
31 | bool isReachable = (flags & NetworkReachabilityFlags.Reachable) != 0;
32 |
33 | // Do we need a connection to reach it?
34 | bool noConnectionRequired = (flags & NetworkReachabilityFlags.ConnectionRequired) == 0;
35 |
36 | // Since the network stack will automatically try to get the WAN up,
37 | // probe that
38 | if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
39 | noConnectionRequired = true;
40 |
41 | return isReachable && noConnectionRequired;
42 | }
43 |
44 | //
45 | ///
46 | /// Is the host reachable with the current network configuration
47 | /// remove http:// and all trailing slashes before use
48 | ///
49 | ///
50 | ///
51 | public static bool IsHostReachable(string host)
52 | {
53 | //host = host.Replace("http://", "");
54 | //host = host.Replace("https://", "");
55 | //host = host.Replace("https://", "");
56 | var uri = new Uri(host);
57 | host = uri.Host;
58 |
59 | if (!string.IsNullOrEmpty(host))
60 | {
61 | using (var r = new NetworkReachability(host))
62 | {
63 | NetworkReachabilityFlags flags;
64 | if (r.TryGetFlags(out flags))
65 | return IsReachableWithoutRequiringConnection(flags);
66 | }
67 | }
68 | return false;
69 | }
70 |
71 | //
72 | // Raised every time there is an interesting reachable event,
73 | // we do not even pass the info as to what changed, and
74 | // we lump all three status we probe into one
75 | //
76 | public static event EventHandler ReachabilityChanged;
77 |
78 | private static void OnChange(NetworkReachabilityFlags flags)
79 | {
80 | var h = ReachabilityChanged;
81 | if (h != null)
82 | h(null, EventArgs.Empty);
83 | }
84 |
85 | private static NetworkReachability defaultRouteReachability;
86 |
87 | private static bool IsNetworkAvailable(out NetworkReachabilityFlags flags)
88 | {
89 | if (defaultRouteReachability == null)
90 | {
91 | defaultRouteReachability = new NetworkReachability(new IPAddress(0));
92 | defaultRouteReachability.SetCallback(OnChange);
93 | defaultRouteReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
94 | }
95 | return defaultRouteReachability.TryGetFlags(out flags)
96 | && IsReachableWithoutRequiringConnection(flags);
97 | }
98 |
99 | //
100 | // Returns true if it is possible to reach the AdHoc WiFi network
101 | // and optionally provides extra network reachability flags as the
102 | // out parameter
103 | //
104 | private static NetworkReachability adHocWiFiNetworkReachability;
105 |
106 | private static bool IsAdHocWiFiNetworkAvailable(out NetworkReachabilityFlags flags)
107 | {
108 | if (adHocWiFiNetworkReachability == null)
109 | {
110 | adHocWiFiNetworkReachability = new NetworkReachability(new IPAddress(new byte[] {169, 254, 0, 0}));
111 | adHocWiFiNetworkReachability.SetCallback(OnChange);
112 | adHocWiFiNetworkReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
113 | }
114 | return adHocWiFiNetworkReachability.TryGetFlags(out flags)
115 | && IsReachableWithoutRequiringConnection(flags);
116 | }
117 |
118 | private static NetworkReachability remoteHostReachability;
119 |
120 | public static Reachability RemoteHostStatus(string hostName)
121 | {
122 | bool reachable;
123 | NetworkReachabilityFlags flags;
124 | if (remoteHostReachability == null)
125 | {
126 | remoteHostReachability = new NetworkReachability(hostName);
127 |
128 | // Need to probe before we queue, or we wont get any meaningful values
129 | // this only happens when you create NetworkReachability from a hostname
130 | reachable = remoteHostReachability.TryGetFlags(out flags);
131 | remoteHostReachability.SetCallback(OnChange);
132 | remoteHostReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
133 | }
134 | else
135 | reachable = remoteHostReachability.TryGetFlags(out flags);
136 |
137 | bool requiresConnection = !IsReachableWithoutRequiringConnection(flags);
138 |
139 | if (!reachable)
140 | return new Reachability() {Status = NetworkStatus.NotReachable, ConnectionRequired = requiresConnection};
141 |
142 | if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
143 | return new Reachability()
144 | {
145 | Status = NetworkStatus.ReachableViaCarrierDataNetwork,
146 | ConnectionRequired = requiresConnection
147 | };
148 |
149 | if (requiresConnection)
150 | return new Reachability() {Status = NetworkStatus.NotReachable, ConnectionRequired = false};
151 |
152 | return new Reachability()
153 | {
154 | Status = NetworkStatus.ReachableViaWiFiNetwork,
155 | ConnectionRequired = requiresConnection
156 | };
157 | }
158 |
159 | public static Reachability InternetConnectionStatus()
160 | {
161 | NetworkReachabilityFlags flags;
162 |
163 | bool defaultNetworkAvailable = IsNetworkAvailable(out flags);
164 | bool requiresConnection = !IsReachableWithoutRequiringConnection(flags);
165 |
166 | Reachability result = new Reachability()
167 | {
168 | ConnectionRequired = requiresConnection,
169 | Status = NetworkStatus.NotReachable
170 | };
171 |
172 | // If the connection is reachable and no connection is required, then assume it's WiFi
173 | if (defaultNetworkAvailable)
174 | {
175 | result.Status = NetworkStatus.ReachableViaWiFiNetwork;
176 | }
177 |
178 | // If the connection is on-demand or on-traffic and no user intervention
179 | // is required, then assume WiFi.
180 | if (((flags & NetworkReachabilityFlags.ConnectionOnDemand) != 0
181 | || (flags & NetworkReachabilityFlags.ConnectionOnTraffic) != 0)
182 | && (flags & NetworkReachabilityFlags.InterventionRequired) == 0)
183 | {
184 | result.Status = NetworkStatus.ReachableViaWiFiNetwork;
185 | }
186 |
187 | // If it's a WWAN connection..
188 | if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
189 | result.Status = NetworkStatus.ReachableViaCarrierDataNetwork;
190 |
191 | return result;
192 | }
193 |
194 | public static Reachability LocalWifiConnectionStatus()
195 | {
196 | NetworkReachabilityFlags flags;
197 | bool wifiAvailable = IsAdHocWiFiNetworkAvailable(out flags);
198 | bool requiresConnection = !IsReachableWithoutRequiringConnection(flags);
199 |
200 | if (wifiAvailable)
201 | {
202 | if ((flags & NetworkReachabilityFlags.IsDirect) != 0)
203 | return new Reachability()
204 | {
205 | Status = NetworkStatus.ReachableViaWiFiNetwork,
206 | ConnectionRequired = requiresConnection
207 | };
208 | }
209 |
210 | return new Reachability() {Status = NetworkStatus.NotReachable, ConnectionRequired = requiresConnection};
211 | }
212 | }
213 | }
--------------------------------------------------------------------------------