Revision 46426dbd

b/trunk/NetSparkle/AssemblyInfo.cs
1
using System.Reflection;
2
using System.Runtime.CompilerServices;
3
using System.Runtime.InteropServices;
4

  
5
// General Information about an assembly is controlled through the following 
6
// set of attributes. Change these attribute values to modify the information
7
// associated with an assembly.
8
[assembly: AssemblyTitle("NetSparkle")]
9
[assembly: AssemblyDescription("NetSparkle is an auto update framework for .NET developers")]
10
[assembly: AssemblyConfiguration("")]
11
[assembly: AssemblyCompany("Dirk Eisenberg")]
12
[assembly: AssemblyProduct("NetSparkle")]
13
[assembly: AssemblyCopyright("Copyright © Dirk Eisenberg 2010")]
14
[assembly: AssemblyTrademark("")]
15
[assembly: AssemblyCulture("")]
16

  
17
// Setting ComVisible to false makes the types in this assembly not visible 
18
// to COM components.  If you need to access a type in this assembly from 
19
// COM, set the ComVisible attribute to true on that type.
20
[assembly: ComVisible(false)]
21

  
22
// The following GUID is for the ID of the typelib if this project is exposed to COM
23
[assembly: Guid("7891583a-a852-4093-9774-3518ed86c978")]
24

  
25
// Version information for an assembly consists of the following four values:
26
//
27
//      Major Version
28
//      Minor Version 
29
//      Build Number
30
//      Revision
31
//
32
// You can specify all the values or you can default the Build and Revision Numbers 
33
// by using the '*' as shown below:
34
// [assembly: AssemblyVersion("1.0.*")]
35
[assembly: AssemblyVersion("1.0.22")]
36
[assembly: AssemblyFileVersion("1.0.22")]
b/trunk/NetSparkle/Interfaces/INetSparkleAssemblyAccessor.cs
1
using System;
2
namespace AppLimit.NetSparkle.Interfaces
3
{
4
    interface INetSparkleAssemblyAccessor
5
    {
6
        string AssemblyCompany { get; }
7
        string AssemblyCopyright { get; }
8
        string AssemblyDescription { get; }
9
        string AssemblyProduct { get; }
10
        string AssemblyTitle { get; }
11
        string AssemblyVersion { get; }
12
    }
13
}
b/trunk/NetSparkle/NetSparkle.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.ComponentModel;
6
using System.Threading;
7
using System.Net;
8
using System.Windows.Forms;
9
using System.Drawing;
10
using System.Runtime.InteropServices;
11
using System.Management;
12
using System.Diagnostics;
13
using System.Security.Cryptography.X509Certificates;
14
using System.Net.Security;
15

  
16
namespace AppLimit.NetSparkle
17
{
18
    public delegate void LoopStartedOperation(Object sender);
19
    public delegate void LoopFinishedOperation(Object sender, Boolean UpdateRequired);
20

  
21
    /// <summary>
22
    /// Everytime when netsparkle detects an update the 
23
    /// consumer can decide what should happen as next with the help 
24
    /// of the UpdateDatected event
25
    /// </summary>
26
    public enum nNextUpdateAction
27
    {
28
        showStandardUserInterface = 1,
29
        performUpdateUnattended = 2,
30
        prohibitUpdate = 3
31
    }
32

  
33
    /// <summary>
34
    /// Contains all information for the update detected event
35
    /// </summary>
36
    public class UpdateDetectedEventArgs : EventArgs
37
    {
38
        public nNextUpdateAction NextAction;
39
        public NetSparkleConfiguration ApplicationConfig;
40
        public NetSparkleAppCastItem LatestVersion;        
41
    }
42

  
43
    /// <summary>
44
    /// This delegate will be used when an update was detected to allow library 
45
    /// consumer to add own user interface capabilities.    
46
    /// </summary>
47
    /// <param name="sender"></param>
48
    /// <param name="e"></param>
49
    public delegate void UpdateDetected(Object sender, UpdateDetectedEventArgs e);
50

  
51
    public class Sparkle : IDisposable
52
    {
53
        private BackgroundWorker _worker = new BackgroundWorker();
54

  
55
        private String _AppCastUrl;
56
        private String _AppReferenceAssembly;
57

  
58
        private Boolean _DoInitialCheck;
59
        private Boolean _ForceInitialCheck;
60

  
61
        private EventWaitHandle _exitHandle;
62
        private EventWaitHandle _loopingHandle;
63
        
64
        private NetSparkleMainWindows _DiagnosticWindow;
65

  
66
        private TimeSpan _CheckFrequency;
67

  
68
        /// <summary>
69
        /// Enables system profiling against a profile server
70
        /// </summary>
71
        public Boolean EnableSystemProfiling = false;
72

  
73
        /// <summary>
74
        /// Hides the release notes view when an update was found. This 
75
        /// mode is switched on automatically when no sparkle:releaseNotesLink
76
        /// tag was found in the app cast         
77
        /// </summary>
78
        public Boolean HideReleaseNotes = false;
79

  
80
        /// <summary>
81
        /// Contains the profile url for System profiling
82
        /// </summary>
83
        public Uri SystemProfileUrl;
84

  
85
        /// <summary>
86
        /// This event will be raised when a check loop will be started
87
        /// </summary>
88
        public event LoopStartedOperation checkLoopStarted;
89

  
90
        /// <summary>
91
        /// This event will be raised when a check loop is finished
92
        /// </summary>
93
        public event LoopFinishedOperation checkLoopFinished;
94

  
95
        /// <summary>
96
        /// This event can be used to override the standard user interface
97
        /// process when an update is detected
98
        /// </summary>
99
        public event UpdateDetected updateDetected;
100

  
101
        /// <summary>
102
        /// This property holds an optional application icon
103
        /// which will be displayed in the software update dialog. The icon has
104
        /// to be 48x48 pixels.
105
        /// </summary>
106
        public Image ApplicationIcon { get; set; }
107

  
108
        /// <summary>
109
        /// This property returns an optional application icon 
110
        /// which will displayed in the windows as self
111
        /// </summary>
112
        public Icon ApplicationWindowIcon { get; set; }
113

  
114
        /// <summary>
115
        /// This property enables a diagnostic window for debug reasons
116
        /// </summary>
117
        public Boolean ShowDiagnosticWindow { get; set; }
118

  
119
        /// <summary>
120
        /// This property enables the silent mode, this means 
121
        /// the application will be updated without user interaction
122
        /// </summary>
123
        public Boolean EnableSilentMode { get; set; }
124

  
125
        /// <summary>
126
        /// This property returns true when the upadete loop is running
127
        /// and files when the loop is not running
128
        /// </summary>
129
        public Boolean IsUpdateLoopRunning
130
        {
131
            get
132
            {
133
                return _loopingHandle.WaitOne(0);
134
            }
135
        }
136

  
137
        /// <summary>
138
        /// This property defines if we trust every ssl connection also when 
139
        /// this connection has not a valid cert
140
        /// </summary>
141
        public Boolean TrustEverySSLConnection { get; set; }      
142

  
143
        /// <summary>
144
        /// ctor which needs the appcast url
145
        /// </summary>
146
        /// <param name="appcastUrl"></param>
147
        public Sparkle(String appcastUrl)
148
            : this(appcastUrl, null)
149
        { }
150

  
151
        /// <summary>
152
        /// ctor which needs the appcast url and a referenceassembly
153
        /// </summary>
154
        public Sparkle(String appcastUrl, String referenceAssembly)
155
            : this(appcastUrl, referenceAssembly, false)
156
        { }
157

  
158
        /// <summary>
159
        /// ctor which needs the appcast url and a referenceassembly
160
        /// </summary>        
161
        public Sparkle(String appcastUrl, String referenceAssembly, Boolean ShowDiagnostic)
162
        {
163
            // preconfige ssl trust
164
            TrustEverySSLConnection = false;
165

  
166
            // configure ssl cert link
167
            ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidation;
168

  
169
            // enable visual style to ensure that we have XP style or higher
170
            // also in WPF applications
171
            System.Windows.Forms.Application.EnableVisualStyles();
172

  
173
            // reset vars
174
            ApplicationIcon = null;
175
            _AppReferenceAssembly = null;            
176

  
177
            // set var
178
            ShowDiagnosticWindow = ShowDiagnostic;
179

  
180
            // create the diagnotic window
181
            _DiagnosticWindow = new NetSparkleMainWindows();
182

  
183
            // set the reference assembly
184
            if (referenceAssembly != null)
185
            {
186
                _AppReferenceAssembly = referenceAssembly;
187
                _DiagnosticWindow.Report("Checking the following file: " + _AppReferenceAssembly);
188
            }
189

  
190
            // show if needed
191
            ShowDiagnosticWindowIfNeeded();            
192

  
193
            // adjust the delegates
194
            _worker.WorkerReportsProgress = true;
195
            _worker.DoWork += new DoWorkEventHandler(_worker_DoWork);
196
            _worker.ProgressChanged += new ProgressChangedEventHandler(_worker_ProgressChanged);
197

  
198
            // build the wait handle
199
            _exitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);
200
            _loopingHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
201

  
202
            // set the url
203
            _AppCastUrl = appcastUrl;
204
            _DiagnosticWindow.Report("Using the following url: " + _AppCastUrl);            
205
        }
206

  
207
        /// <summary>
208
        /// The method starts a NetSparkle background loop
209
        /// If NetSparkle is configured to check for updates on startup, proceeds to perform 
210
        /// the check. You should only call this function when your app is initialized and 
211
        /// shows its main window.        
212
        /// </summary>        
213
        /// <param name="doInitialCheck"></param>
214
        public void StartLoop(Boolean doInitialCheck)
215
        {
216
            StartLoop(doInitialCheck, false);
217
        }
218

  
219
        /// <summary>
220
        /// The method starts a NetSparkle background loop
221
        /// If NetSparkle is configured to check for updates on startup, proceeds to perform 
222
        /// the check. You should only call this function when your app is initialized and 
223
        /// shows its main window.
224
        /// </summary>
225
        /// <param name="doInitialCheck"></param>
226
        /// <param name="checkFrequency"></param>
227
        public void StartLoop(Boolean doInitialCheck, TimeSpan checkFrequency)
228
        {
229
            StartLoop(doInitialCheck, false, checkFrequency);
230
        }
231

  
232
        /// <summary>
233
        /// The method starts a NetSparkle background loop
234
        /// If NetSparkle is configured to check for updates on startup, proceeds to perform 
235
        /// the check. You should only call this function when your app is initialized and 
236
        /// shows its main window.
237
        /// </summary>
238
        /// <param name="doInitialCheck"></param>
239
        /// <param name="forceInitialCheck"></param>
240
        public void StartLoop(Boolean doInitialCheck, Boolean forceInitialCheck)
241
        {
242
            StartLoop(doInitialCheck, forceInitialCheck, TimeSpan.FromHours(24));
243
        }
244

  
245
        /// <summary>
246
        /// The method starts a NetSparkle background loop
247
        /// If NetSparkle is configured to check for updates on startup, proceeds to perform 
248
        /// the check. You should only call this function when your app is initialized and 
249
        /// shows its main window.
250
        /// </summary>
251
        /// <param name="doInitialCheck"></param>
252
        /// <param name="forceInitialCheck"></param>
253
        /// <param name="checkFrequency"></param>
254
        public void StartLoop(Boolean doInitialCheck, Boolean forceInitialCheck, TimeSpan checkFrequency)
255
        {
256
            // first set the event handle
257
            _loopingHandle.Set();
258

  
259
            // Start the helper thread as a background worker to 
260
            // get well ui interaction                        
261

  
262
            // show if needed
263
            ShowDiagnosticWindowIfNeeded();
264

  
265
            // store infos
266
            _DoInitialCheck = doInitialCheck;
267
            _ForceInitialCheck = forceInitialCheck;
268
            _CheckFrequency = checkFrequency;
269

  
270
            // create and configure the worker
271
            _DiagnosticWindow.Report("Starting background worker");
272

  
273
            // start the work
274
            _worker.RunWorkerAsync();
275
        }
276

  
277
        /// <summary>
278
        /// This method will stop the sparkle background loop and is called
279
        /// through the disposable interface automatically
280
        /// </summary>
281
        public void StopLoop()
282
        {
283
            // ensure the work will finished
284
            _exitHandle.Set();                       
285
        }
286

  
287
        /// <summary>
288
        /// Is called in the using context and will stop all background activities
289
        /// </summary>
290
        public void Dispose()
291
        {
292
            StopLoop();
293
        }
294

  
295
        /// <summary>
296
        /// This method updates the profile information which can be sended to the server if enabled    
297
        /// </summary>
298
        /// <param name="config"></param>
299
        public void UpdateSystemProfileInformation(NetSparkleConfiguration config)
300
        {
301
            // check if profile data is enabled
302
            if (!EnableSystemProfiling)
303
                return;
304

  
305
            // check if we need an update
306
            if (DateTime.Now - config.LastProfileUpdate < new TimeSpan(7, 0, 0, 0))
307
                return;
308

  
309
            // touch the profile update time
310
            config.TouchProfileTime();
311

  
312
            // start the profile thread
313
            Thread t = new Thread(ProfileDataThreadStart);
314
            t.Start(config);
315
        }
316

  
317
        /// <summary>
318
        /// Profile data thread
319
        /// </summary>
320
        /// <param name="obj"></param>
321
        private void ProfileDataThreadStart(object obj)
322
        {
323
            try
324
            {
325
                if (SystemProfileUrl != null)
326
                {
327
                    // get the config
328
                    NetSparkleConfiguration config = obj as NetSparkleConfiguration;
329

  
330
                    // collect data
331
                    NetSparkleDeviceInventory inv = new NetSparkleDeviceInventory(config);
332
                    inv.CollectInventory();
333

  
334
                    // build url
335
                    String requestUrl = inv.BuildRequestUrl(SystemProfileUrl.ToString() + "?");
336

  
337
                    HttpWebRequest.DefaultWebProxy = HttpWebRequest.GetSystemWebProxy();
338

  
339
                    // perform the webrequest
340
                    HttpWebRequest request = HttpWebRequest.Create(requestUrl) as HttpWebRequest;
341
                    using (WebResponse response = request.GetResponse())
342
                    {
343
                        // close the response 
344
                        response.Close();
345
                    }
346
                }
347
            }
348
            catch (Exception ex)
349
            {
350
                // No exception during data send 
351
                ReportDiagnosticMessage(ex.Message);
352
            }
353
        }
354

  
355
        /// <summary>
356
        /// This method checks if an update is required. During this process the appcast
357
        /// will be downloaded and checked against the reference assembly. Ensure that
358
        /// the calling process has access to the internet and read access to the 
359
        /// reference assembly. This method is also called from the background loops.
360
        /// </summary>
361
        /// <param name="config"></param>
362
        /// <returns></returns>
363
        public Boolean IsUpdateRequired(NetSparkleConfiguration config, out NetSparkleAppCastItem latestVersion)
364
        {
365
            // report
366
            ReportDiagnosticMessage("Downloading and checking appcast");
367

  
368
            // init the appcast
369
            NetSparkleAppCast cast = new NetSparkleAppCast(_AppCastUrl, config);
370

  
371
            // check if any updates are available
372
            try
373
            {
374
                latestVersion = cast.GetLatestVersion();
375
            }
376
            catch (Exception e)
377
            {
378
                // show the exeception message 
379
                ReportDiagnosticMessage("Error during app cast download: " + e.Message);
380

  
381
                // just null the version info
382
                latestVersion = null;
383
            }
384

  
385
            if (latestVersion == null)
386
            {
387
                ReportDiagnosticMessage("No version information in app cast found");
388
                return false;
389
            }
390
            else
391
            {
392
                ReportDiagnosticMessage("Lastest version on the server is " + latestVersion.Version);
393
            }
394

  
395
            // set the last check time
396
            ReportDiagnosticMessage("Touch the last check timestamp");
397
            config.TouchCheckTime();
398

  
399
            // check if the available update has to be skipped
400
            if (latestVersion.Version.Equals(config.SkipThisVersion))
401
            {
402
                ReportDiagnosticMessage("Latest update has to be skipped (user decided to skip version " + config.SkipThisVersion + ")");
403
                return false;
404
            }
405

  
406
            // check if the version will be the same then the installed version
407
            Version v1 = new Version(config.InstalledVersion);
408
            Version v2 = new Version(latestVersion.Version);
409

  
410
            if (v2 <= v1)
411
            {
412
                ReportDiagnosticMessage("Installed version is valid, no update needed (" + config.InstalledVersion + ")");
413
                return false;
414
            }
415

  
416
            // ok we need an update
417
            return true;
418
        }
419

  
420
        /// <summary>
421
        /// This method reads the local sparkle configuration for the given
422
        /// reference assembly
423
        /// </summary>
424
        /// <param name="AppReferenceAssembly"></param>
425
        /// <returns></returns>
426
        public NetSparkleConfiguration GetApplicationConfig()
427
        {
428
            NetSparkleConfiguration config;
429
            config = new NetSparkleConfiguration(_AppReferenceAssembly);
430
            return config;
431
        }
432

  
433
        /// <summary>
434
        /// This method shows the update ui and allows to perform the 
435
        /// update process
436
        /// </summary>
437
        /// <param name="currentItem"></param>
438
        public void ShowUpdateNeededUI(NetSparkleAppCastItem currentItem)
439
        {
440
            // create the form
441
            NetSparkleForm frm = new NetSparkleForm(currentItem, ApplicationIcon, ApplicationWindowIcon);
442

  
443
            // configure the form
444
            frm.TopMost = true;
445

  
446
            if (HideReleaseNotes)
447
                frm.RemoveReleaseNotesControls();
448
            
449
            // show it
450
            DialogResult dlgResult = frm.ShowDialog();
451
            
452

  
453
            if (dlgResult == DialogResult.No)
454
            {
455
                // skip this version
456
                NetSparkleConfiguration config = new NetSparkleConfiguration(_AppReferenceAssembly);
457
                config.SetVersionToSkip(currentItem.Version);
458
            }
459
            else if (dlgResult == DialogResult.Yes)
460
            {
461
                // download the binaries
462
                InitDownloadAndInstallProcess(currentItem);
463
            }
464
            
465
        }
466

  
467
        /// <summary>
468
        /// This method reports a message in the diagnostic window
469
        /// </summary>
470
        /// <param name="message"></param>
471
        public void ReportDiagnosticMessage(String message)
472
        {
473
            if (_DiagnosticWindow.InvokeRequired)
474
            {
475
                _DiagnosticWindow.Invoke(new Action<String>(ReportDiagnosticMessage), message);                
476
            }
477
            else
478
            {
479
                _DiagnosticWindow.Report(message);
480
            }
481
        }
482

  
483
        /// <summary>
484
        /// This method will be executed as worker thread
485
        /// </summary>
486
        /// <param name="sender"></param>
487
        /// <param name="e"></param>
488
        void _worker_DoWork(object sender, DoWorkEventArgs e)
489
        {
490
            // store the did run once feature
491
            Boolean goIntoLoop = true;
492
            Boolean checkTSP = true;
493
            Boolean doInitialCheck = _DoInitialCheck;
494
            Boolean isInitialCheck = true;
495

  
496
            // start our lifecycles
497
            do
498
            {
499
                // set state
500
                Boolean bUpdateRequired = false;
501

  
502
                // notify
503
                if (checkLoopStarted != null)
504
                    checkLoopStarted(this);
505

  
506
                // report status
507
                if (doInitialCheck == false)
508
                {
509
                    ReportDiagnosticMessage("Initial check prohibited, going to wait");
510
                    doInitialCheck = true;
511
                    goto WaitSection;
512
                }
513

  
514
                // report status
515
                ReportDiagnosticMessage("Starting update loop...");
516

  
517
                // read the config
518
                ReportDiagnosticMessage("Reading config...");
519
                NetSparkleConfiguration config = GetApplicationConfig();
520

  
521
                // calc CheckTasp
522
                Boolean checkTSPInternal = checkTSP;
523

  
524
                if (isInitialCheck && checkTSPInternal)
525
                    checkTSPInternal = !_ForceInitialCheck;
526

  
527
                // check if it's ok the recheck to software state
528
                if (checkTSPInternal)
529
                {
530
                    TimeSpan csp = DateTime.Now - config.LastCheckTime;
531
                    if (csp < _CheckFrequency)
532
                    {
533
                        ReportDiagnosticMessage(String.Format("Update check performed within the last {0} minutes!", _CheckFrequency.TotalMinutes));
534
                        goto WaitSection;
535
                    }
536
                }
537
                else
538
                    checkTSP = true;
539

  
540
                // when sparkle will be deactivated wait an other cycle
541
                if (config.CheckForUpdate == false)
542
                {
543
                    ReportDiagnosticMessage("Check for updates disabled");
544
                    goto WaitSection;
545
                }
546

  
547
                // update the runonce feature
548
                goIntoLoop = !config.DidRunOnce;
549

  
550
                // update profile information is needed
551
                UpdateSystemProfileInformation(config);
552

  
553
                // check if update is required
554
                NetSparkleAppCastItem latestVersion = null;
555
                bUpdateRequired = IsUpdateRequired(config, out latestVersion);
556
                if (!bUpdateRequired)
557
                    goto WaitSection;
558

  
559
                // show the update window
560
                ReportDiagnosticMessage("Update needed from version " + config.InstalledVersion + " to version " + latestVersion.Version);
561

  
562
                // send notification if needed
563
                UpdateDetectedEventArgs ev = new UpdateDetectedEventArgs() { NextAction = nNextUpdateAction.showStandardUserInterface, ApplicationConfig = config, LatestVersion = latestVersion };
564
                if (updateDetected != null)
565
                    updateDetected(this, ev);
566
                
567
                // check results
568
                switch(ev.NextAction)
569
                {
570
                    case nNextUpdateAction.performUpdateUnattended:
571
                        {
572
                            ReportDiagnosticMessage("Unattended update whished from consumer");
573
                            EnableSilentMode = true;
574
                            _worker.ReportProgress(1, latestVersion);
575
                            break;
576
                        }
577
                    case nNextUpdateAction.prohibitUpdate:
578
                        {
579
                            ReportDiagnosticMessage("Update prohibited from consumer");
580
                            break;
581
                        }
582
                    case nNextUpdateAction.showStandardUserInterface:
583
                    default:
584
                        {
585
                            ReportDiagnosticMessage("Standard UI update whished from consumer");
586
                            _worker.ReportProgress(1, latestVersion);
587
                            break;
588
                        }
589
                }                
590

  
591
            WaitSection:
592
                // reset initialcheck
593
                isInitialCheck = false;
594

  
595
                // notify
596
                if (checkLoopFinished != null)
597
                    checkLoopFinished(this, bUpdateRequired);
598

  
599
                // report wait statement
600
                ReportDiagnosticMessage(String.Format("Sleeping for an other {0} minutes, exit event or force update check event", _CheckFrequency.TotalMinutes));
601

  
602
                // wait for
603
                if (!goIntoLoop)
604
                    break;
605
                else
606
                {
607
                    // build the event array
608
                    WaitHandle[] handles = new WaitHandle[1];
609
                    handles[0] = _exitHandle;
610

  
611
                    // wait for any
612
                    int i = WaitHandle.WaitAny(handles, _CheckFrequency);
613
                    if (WaitHandle.WaitTimeout == i)
614
                    {
615
                        ReportDiagnosticMessage(String.Format("{0} minutes are over", _CheckFrequency.TotalMinutes));
616
                        continue;
617
                    }
618

  
619
                    // check the exit hadnle
620
                    if (i == 0)
621
                    {
622
                        ReportDiagnosticMessage("Got exit signal");
623
                        break;
624
                    }
625

  
626
                    // check an other check needed
627
                    if (i == 1)
628
                    {
629
                        ReportDiagnosticMessage("Got force update check signal");
630
                        checkTSP = false;
631
                        continue;
632
                    }
633
                }
634
            } while (goIntoLoop);
635

  
636
            // reset the islooping handle
637
            _loopingHandle.Reset();
638
        }
639

  
640
        /// <summary>
641
        /// This method will be notified
642
        /// </summary>
643
        /// <param name="sender"></param>
644
        /// <param name="e"></param>
645
        private void _worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
646
        {
647
            switch (e.ProgressPercentage)
648
            {
649
                case 1:
650
                    {
651
                        // get the current item
652
                        NetSparkleAppCastItem currentItem = e.UserState as NetSparkleAppCastItem;
653

  
654
                        // show the update ui
655
                        if (EnableSilentMode == true)
656
                            InitDownloadAndInstallProcess(currentItem);
657
                        else
658
                            ShowUpdateNeededUI(currentItem);
659

  
660
                        break;
661
                    }
662
                case 0:
663
                    {
664
                        ReportDiagnosticMessage(e.UserState.ToString());
665
                        break;
666
                    }
667
            }
668
        }
669

  
670
        private void InitDownloadAndInstallProcess(NetSparkleAppCastItem item)
671
        {
672
            NetSparkleDownloadProgress dlProgress = new NetSparkleDownloadProgress(this, item, _AppReferenceAssembly, ApplicationIcon, ApplicationWindowIcon, EnableSilentMode);
673
            dlProgress.ShowDialog();
674
        }
675

  
676
        private void ShowDiagnosticWindowIfNeeded()
677
        {
678
            if (_DiagnosticWindow.InvokeRequired)
679
            {
680
                _DiagnosticWindow.Invoke(new Action(ShowDiagnosticWindowIfNeeded));
681
            }
682
            else
683
            {
684
                // check the diagnotic value
685
                NetSparkleConfiguration config = new NetSparkleConfiguration(_AppReferenceAssembly);
686
                if (config.ShowDiagnosticWindow || ShowDiagnosticWindow)
687
                {
688
                    Point newLocation = new Point();
689

  
690
                    newLocation.X = Screen.PrimaryScreen.Bounds.Width - _DiagnosticWindow.Width;
691
                    newLocation.Y = 0;
692

  
693
                    _DiagnosticWindow.Location = newLocation;
694
                    _DiagnosticWindow.Show();
695
                }
696
            }
697
        }
698

  
699
        private bool RemoteCertificateValidation(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
700
        {
701
            if (TrustEverySSLConnection)
702
            {
703
                // verify if we talk about our app cast dll 
704
                HttpWebRequest req = sender as HttpWebRequest;
705
                if (req == null)
706
                    return (certificate is X509Certificate2) ? ((X509Certificate2)certificate).Verify() : false;
707

  
708
                // if so just return our trust 
709
                if (req.RequestUri.Equals(new Uri(_AppCastUrl)))
710
                    return true;
711
                else
712
                    return (certificate is X509Certificate2) ? ((X509Certificate2)certificate).Verify() : false;
713
            }
714
            else
715
            {
716
                // check our cert                 
717
                return (certificate is X509Certificate2) ? ((X509Certificate2)certificate).Verify() : false;
718
            }
719
        }
720
    }
721
}
b/trunk/NetSparkle/NetSparkle.csproj
1
<?xml version="1.0" encoding="utf-8"?>
2
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
  <PropertyGroup>
4
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6
    <ProductVersion>9.0.30729</ProductVersion>
7
    <SchemaVersion>2.0</SchemaVersion>
8
    <ProjectGuid>{74635A21-2BAD-4522-AB95-E3E5703CD301}</ProjectGuid>
9
    <OutputType>Library</OutputType>
10
    <AppDesignerFolder>Properties</AppDesignerFolder>
11
    <RootNamespace>AppLimit.NetSparkle</RootNamespace>
12
    <AssemblyName>AppLimit.NetSparkle</AssemblyName>
13
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
14
    <FileAlignment>512</FileAlignment>
15
  </PropertyGroup>
16
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17
    <DebugSymbols>true</DebugSymbols>
18
    <DebugType>full</DebugType>
19
    <Optimize>false</Optimize>
20
    <OutputPath>bin\Debug\</OutputPath>
21
    <DefineConstants>DEBUG;TRACE</DefineConstants>
22
    <ErrorReport>prompt</ErrorReport>
23
    <WarningLevel>4</WarningLevel>
24
  </PropertyGroup>
25
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26
    <DebugType>pdbonly</DebugType>
27
    <Optimize>true</Optimize>
28
    <OutputPath>bin\Release\</OutputPath>
29
    <DefineConstants>TRACE</DefineConstants>
30
    <ErrorReport>prompt</ErrorReport>
31
    <WarningLevel>4</WarningLevel>
32
  </PropertyGroup>
33
  <ItemGroup>
34
    <Reference Include="System" />
35
    <Reference Include="System.Core">
36
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
37
    </Reference>
38
    <Reference Include="System.Drawing" />
39
    <Reference Include="System.Management" />
40
    <Reference Include="System.Windows.Forms" />
41
    <Reference Include="System.Xml.Linq">
42
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
43
    </Reference>
44
    <Reference Include="System.Data.DataSetExtensions">
45
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
46
    </Reference>
47
    <Reference Include="System.Data" />
48
    <Reference Include="System.Xml" />
49
  </ItemGroup>
50
  <ItemGroup>
51
    <Compile Include="..\AssemblyInfo.cs">
52
      <Link>Properties\AssemblyInfo.cs</Link>
53
    </Compile>
54
    <Compile Include="NetSparkle.cs" />
55
    <Compile Include="NetSparkleAppCaseItem.cs" />
56
    <Compile Include="NetSparkleAppCast.cs" />
57
    <Compile Include="NetSparkleAssemblyAccessor.cs" />
58
    <Compile Include="NetSparkleConfiguration.cs" />
59
    <Compile Include="NetSparkleDeviceInventory.cs" />
60
    <Compile Include="NetSparkleDownloadProgress.cs">
61
      <SubType>Form</SubType>
62
    </Compile>
63
    <Compile Include="NetSparkleDownloadProgress.Designer.cs">
64
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
65
    </Compile>
66
    <Compile Include="NetSparkleDSAVerificator.cs" />
67
    <Compile Include="NetSparkleForm.cs">
68
      <SubType>Form</SubType>
69
    </Compile>
70
    <Compile Include="NetSparkleForm.Designer.cs">
71
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
72
    </Compile>
73
    <Compile Include="NetSparkleMainWindows.cs">
74
      <SubType>Form</SubType>
75
    </Compile>
76
    <Compile Include="NetSparkleMainWindows.Designer.cs">
77
      <DependentUpon>NetSparkleMainWindows.cs</DependentUpon>
78
    </Compile>
79
    <Compile Include="Properties\Resources.Designer.cs">
80
      <AutoGen>True</AutoGen>
81
      <DesignTime>True</DesignTime>
82
      <DependentUpon>Resources.resx</DependentUpon>
83
    </Compile>
84
  </ItemGroup>
85
  <ItemGroup>
86
    <EmbeddedResource Include="NetSparkleDownloadProgress.bg.resx">
87
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
88
    </EmbeddedResource>
89
    <EmbeddedResource Include="NetSparkleDownloadProgress.de.resx">
90
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
91
    </EmbeddedResource>
92
    <EmbeddedResource Include="NetSparkleDownloadProgress.es-MX.resx">
93
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
94
    </EmbeddedResource>
95
    <EmbeddedResource Include="NetSparkleDownloadProgress.fr.resx">
96
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
97
    </EmbeddedResource>
98
    <EmbeddedResource Include="NetSparkleDownloadProgress.it.resx">
99
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
100
    </EmbeddedResource>
101
    <EmbeddedResource Include="NetSparkleDownloadProgress.lt.resx">
102
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
103
    </EmbeddedResource>
104
    <EmbeddedResource Include="NetSparkleDownloadProgress.nl.resx">
105
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
106
    </EmbeddedResource>
107
    <EmbeddedResource Include="NetSparkleDownloadProgress.pt-BR.resx">
108
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
109
    </EmbeddedResource>
110
    <EmbeddedResource Include="NetSparkleDownloadProgress.resx">
111
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
112
    </EmbeddedResource>
113
    <EmbeddedResource Include="NetSparkleDownloadProgress.ru.resx">
114
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
115
    </EmbeddedResource>
116
    <EmbeddedResource Include="NetSparkleDownloadProgress.zh-CN.resx">
117
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
118
    </EmbeddedResource>
119
    <EmbeddedResource Include="NetSparkleDownloadProgress.zh-TW.resx">
120
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
121
    </EmbeddedResource>
122
    <EmbeddedResource Include="NetSparkleForm.bg.resx">
123
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
124
    </EmbeddedResource>
125
    <EmbeddedResource Include="NetSparkleForm.de.resx">
126
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
127
    </EmbeddedResource>
128
    <EmbeddedResource Include="NetSparkleForm.es-MX.resx">
129
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
130
    </EmbeddedResource>
131
    <EmbeddedResource Include="NetSparkleForm.fr.resx">
132
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
133
    </EmbeddedResource>
134
    <EmbeddedResource Include="NetSparkleForm.it.resx">
135
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
136
    </EmbeddedResource>
137
    <EmbeddedResource Include="NetSparkleForm.lt.resx">
138
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
139
    </EmbeddedResource>
140
    <EmbeddedResource Include="NetSparkleForm.nl.resx">
141
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
142
    </EmbeddedResource>
143
    <EmbeddedResource Include="NetSparkleForm.pt-BR.resx">
144
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
145
    </EmbeddedResource>
146
    <EmbeddedResource Include="NetSparkleForm.resx">
147
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
148
    </EmbeddedResource>
149
    <EmbeddedResource Include="NetSparkleForm.ru.resx">
150
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
151
    </EmbeddedResource>
152
    <EmbeddedResource Include="NetSparkleForm.zh-CN.resx">
153
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
154
    </EmbeddedResource>
155
    <EmbeddedResource Include="NetSparkleForm.zh-TW.resx">
156
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
157
    </EmbeddedResource>
158
    <EmbeddedResource Include="NetSparkleMainWindows.resx">
159
      <DependentUpon>NetSparkleMainWindows.cs</DependentUpon>
160
    </EmbeddedResource>
161
    <EmbeddedResource Include="Properties\Resources.resx">
162
      <Generator>ResXFileCodeGenerator</Generator>
163
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
164
    </EmbeddedResource>
165
  </ItemGroup>
166
  <ItemGroup>
167
    <None Include="ArtWork\software-update-available.png" />
168
  </ItemGroup>
169
  <ItemGroup>
170
    <Folder Include="Resources\" />
171
  </ItemGroup>
172
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
173
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
174
       Other similar extension points exist, see Microsoft.Common.targets.
175
  <Target Name="BeforeBuild">
176
  </Target>
177
  <Target Name="AfterBuild">
178
  </Target>
179
  -->
180
</Project>
b/trunk/NetSparkle/NetSparkle2010.csproj
1
<?xml version="1.0" encoding="utf-8"?>
2
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
  <PropertyGroup>
4
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6
    <ProductVersion>9.0.30729</ProductVersion>
7
    <SchemaVersion>2.0</SchemaVersion>
8
    <ProjectGuid>{74635A21-2BAD-4522-AB95-E3E5703CD301}</ProjectGuid>
9
    <OutputType>Library</OutputType>
10
    <AppDesignerFolder>Properties</AppDesignerFolder>
11
    <RootNamespace>AppLimit.NetSparkle</RootNamespace>
12
    <AssemblyName>AppLimit.NetSparkle.Net40</AssemblyName>
13
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14
    <FileAlignment>512</FileAlignment>
15
    <FileUpgradeFlags>
16
    </FileUpgradeFlags>
17
    <OldToolsVersion>3.5</OldToolsVersion>
18
    <UpgradeBackupLocation />
19
    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
20
    <PublishUrl>publish\</PublishUrl>
21
    <Install>true</Install>
22
    <InstallFrom>Disk</InstallFrom>
23
    <UpdateEnabled>false</UpdateEnabled>
24
    <UpdateMode>Foreground</UpdateMode>
25
    <UpdateInterval>7</UpdateInterval>
26
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
27
    <UpdatePeriodically>false</UpdatePeriodically>
28
    <UpdateRequired>false</UpdateRequired>
29
    <MapFileExtensions>true</MapFileExtensions>
30
    <ApplicationRevision>0</ApplicationRevision>
31
    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
32
    <IsWebBootstrapper>false</IsWebBootstrapper>
33
    <UseApplicationTrust>false</UseApplicationTrust>
34
    <BootstrapperEnabled>true</BootstrapperEnabled>
35
    <SccProjectName>SAK</SccProjectName>
36
    <SccLocalPath>SAK</SccLocalPath>
37
    <SccAuxPath>SAK</SccAuxPath>
38
    <SccProvider>SAK</SccProvider>
39
  </PropertyGroup>
40
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
41
    <DebugSymbols>true</DebugSymbols>
42
    <DebugType>full</DebugType>
43
    <Optimize>false</Optimize>
44
    <OutputPath>Debug\lib\net40-full\</OutputPath>
45
    <DefineConstants>DEBUG;TRACE</DefineConstants>
46
    <ErrorReport>prompt</ErrorReport>
47
    <WarningLevel>4</WarningLevel>
48
  </PropertyGroup>
49
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
50
    <DebugType>pdbonly</DebugType>
51
    <Optimize>true</Optimize>
52
    <OutputPath>Release\lib\net40-full\</OutputPath>
53
    <DefineConstants>TRACE</DefineConstants>
54
    <ErrorReport>prompt</ErrorReport>
55
    <WarningLevel>4</WarningLevel>
56
  </PropertyGroup>
57
  <PropertyGroup>
58
    <SignAssembly>true</SignAssembly>
59
  </PropertyGroup>
60
  <PropertyGroup>
61
    <AssemblyOriginatorKeyFile>pithos.snk</AssemblyOriginatorKeyFile>
62
  </PropertyGroup>
63
  <ItemGroup>
64
    <Reference Include="System" />
65
    <Reference Include="System.Core">
66
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
67
    </Reference>
68
    <Reference Include="System.Drawing" />
69
    <Reference Include="System.Management" />
70
    <Reference Include="System.Windows.Forms" />
71
    <Reference Include="System.Xml.Linq">
72
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
73
    </Reference>
74
    <Reference Include="System.Data.DataSetExtensions">
75
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
76
    </Reference>
77
    <Reference Include="System.Data" />
78
    <Reference Include="System.Xml" />
79
  </ItemGroup>
80
  <ItemGroup>
81
    <Compile Include="AssemblyInfo.cs" />
82
    <Compile Include="NetSparkleAssemblyReflectionAccessor.cs" />
83
    <Compile Include="Interfaces\INetSparkleAssemblyAccessor.cs" />
84
    <Compile Include="NetSparkle.cs" />
85
    <Compile Include="NetSparkleAppCaseItem.cs" />
86
    <Compile Include="NetSparkleAppCast.cs" />
87
    <Compile Include="NetSparkleAssemblyAccessor.cs" />
88
    <Compile Include="NetSparkleAssemblyDiagnosticsAccessor.cs" />
89
    <Compile Include="NetSparkleConfiguration.cs" />
90
    <Compile Include="NetSparkleDeviceInventory.cs" />
91
    <Compile Include="NetSparkleDownloadProgress.cs">
92
      <SubType>Form</SubType>
93
    </Compile>
94
    <Compile Include="NetSparkleDownloadProgress.Designer.cs">
95
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
96
    </Compile>
97
    <Compile Include="NetSparkleDSAVerificator.cs" />
98
    <Compile Include="NetSparkleForm.cs">
99
      <SubType>Form</SubType>
100
    </Compile>
101
    <Compile Include="NetSparkleForm.Designer.cs">
102
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
103
    </Compile>
104
    <Compile Include="NetSparkleMainWindows.cs">
105
      <SubType>Form</SubType>
106
    </Compile>
107
    <Compile Include="NetSparkleMainWindows.Designer.cs">
108
      <DependentUpon>NetSparkleMainWindows.cs</DependentUpon>
109
    </Compile>
110
    <Compile Include="Properties\Resources.Designer.cs">
111
      <AutoGen>True</AutoGen>
112
      <DesignTime>True</DesignTime>
113
      <DependentUpon>Resources.resx</DependentUpon>
114
    </Compile>
115
  </ItemGroup>
116
  <ItemGroup>
117
    <EmbeddedResource Include="NetSparkleDownloadProgress.bg.resx">
118
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
119
    </EmbeddedResource>
120
    <EmbeddedResource Include="NetSparkleDownloadProgress.de.resx">
121
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
122
    </EmbeddedResource>
123
    <EmbeddedResource Include="NetSparkleDownloadProgress.es-MX.resx">
124
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
125
    </EmbeddedResource>
126
    <EmbeddedResource Include="NetSparkleDownloadProgress.fr.resx">
127
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
128
    </EmbeddedResource>
129
    <EmbeddedResource Include="NetSparkleDownloadProgress.it.resx">
130
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
131
    </EmbeddedResource>
132
    <EmbeddedResource Include="NetSparkleDownloadProgress.lt.resx">
133
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
134
    </EmbeddedResource>
135
    <EmbeddedResource Include="NetSparkleDownloadProgress.nl.resx">
136
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
137
    </EmbeddedResource>
138
    <EmbeddedResource Include="NetSparkleDownloadProgress.pt-BR.resx">
139
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
140
    </EmbeddedResource>
141
    <EmbeddedResource Include="NetSparkleDownloadProgress.resx">
142
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
143
    </EmbeddedResource>
144
    <EmbeddedResource Include="NetSparkleDownloadProgress.ru.resx">
145
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
146
    </EmbeddedResource>
147
    <EmbeddedResource Include="NetSparkleDownloadProgress.zh-CN.resx">
148
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
149
    </EmbeddedResource>
150
    <EmbeddedResource Include="NetSparkleDownloadProgress.zh-TW.resx">
151
      <DependentUpon>NetSparkleDownloadProgress.cs</DependentUpon>
152
    </EmbeddedResource>
153
    <EmbeddedResource Include="NetSparkleForm.bg.resx">
154
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
155
    </EmbeddedResource>
156
    <EmbeddedResource Include="NetSparkleForm.de.resx">
157
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
158
    </EmbeddedResource>
159
    <EmbeddedResource Include="NetSparkleForm.es-MX.resx">
160
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
161
    </EmbeddedResource>
162
    <EmbeddedResource Include="NetSparkleForm.fr.resx">
163
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
164
    </EmbeddedResource>
165
    <EmbeddedResource Include="NetSparkleForm.it.resx">
166
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
167
    </EmbeddedResource>
168
    <EmbeddedResource Include="NetSparkleForm.lt.resx">
169
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
170
    </EmbeddedResource>
171
    <EmbeddedResource Include="NetSparkleForm.nl.resx">
172
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
173
    </EmbeddedResource>
174
    <EmbeddedResource Include="NetSparkleForm.pt-BR.resx">
175
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
176
    </EmbeddedResource>
177
    <EmbeddedResource Include="NetSparkleForm.resx">
178
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
179
    </EmbeddedResource>
180
    <EmbeddedResource Include="NetSparkleForm.ru.resx">
181
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
182
    </EmbeddedResource>
183
    <EmbeddedResource Include="NetSparkleForm.zh-CN.resx">
184
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
185
    </EmbeddedResource>
186
    <EmbeddedResource Include="NetSparkleForm.zh-TW.resx">
187
      <DependentUpon>NetSparkleForm.cs</DependentUpon>
188
    </EmbeddedResource>
189
    <EmbeddedResource Include="NetSparkleMainWindows.resx">
190
      <DependentUpon>NetSparkleMainWindows.cs</DependentUpon>
191
    </EmbeddedResource>
192
    <EmbeddedResource Include="Properties\Resources.resx">
193
      <Generator>ResXFileCodeGenerator</Generator>
194
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
195
    </EmbeddedResource>
196
  </ItemGroup>
197
  <ItemGroup>
198
    <None Include="ArtWork\software-update-available.png" />
199
    <None Include="pithos.snk" />
200
  </ItemGroup>
201
  <ItemGroup>
202
    <Folder Include="Resources\" />
203
  </ItemGroup>
204
  <ItemGroup>
205
    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
206
      <Visible>False</Visible>
207
      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
208
      <Install>false</Install>
209
    </BootstrapperPackage>
210
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
211
      <Visible>False</Visible>
212
      <ProductName>.NET Framework 3.5 SP1</ProductName>
213
      <Install>true</Install>
214
    </BootstrapperPackage>
215
    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
216
      <Visible>False</Visible>
217
      <ProductName>Windows Installer 3.1</ProductName>
218
      <Install>true</Install>
219
    </BootstrapperPackage>
220
  </ItemGroup>
221
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
222
  <PropertyGroup>
223
    <PostBuildEvent>
224
    </PostBuildEvent>
225
  </PropertyGroup>
226
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
227
       Other similar extension points exist, see Microsoft.Common.targets.
228
  <Target Name="BeforeBuild">
229
  </Target>
230
  <Target Name="AfterBuild">
231
  </Target>
232
  -->
233
</Project>
b/trunk/NetSparkle/NetSparkleAppCaseItem.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5

  
6
namespace AppLimit.NetSparkle
7
{
8
    public class NetSparkleAppCastItem : IComparable<NetSparkleAppCastItem>
9
    {
10
        public String AppName;
11
        public String AppVersionInstalled;
12

  
13
        public String Version;
14
        public String ReleaseNotesLink;
15
        public String DownloadLink;
16

  
17
        public String DSASignature;
18

  
19
        #region IComparable<NetSparkleAppCastItem> Members
20

  
21
        public int CompareTo(NetSparkleAppCastItem other)
22
        {
23
            Version v1 = new Version(this.Version);
24
            Version v2 = new Version(other.Version);
25

  
26
            return v1.CompareTo(v2);            
27
        }
28

  
29
        #endregion
30
    }    
31
}
b/trunk/NetSparkle/NetSparkleAppCast.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.IO;
6
using System.Xml;
7
using System.Net;
8

  
9
namespace AppLimit.NetSparkle
10
{
11
    public class NetSparkleAppCast
12
    {
13
        private NetSparkleConfiguration _config;
14
        private String _castUrl;
15

  
16
        private const String itemNode = "item";
17
        private const String enclosureNode = "enclosure";
18
        private const String releaseNotesLinkNode = "sparkle:releaseNotesLink";
19
        private const String versionAttribute = "sparkle:version";
20
        private const String dasSignature = "sparkle:dsaSignature";
21
        private const String urlAttribute = "url";
22

  
23
        public NetSparkleAppCast(String castUrl, NetSparkleConfiguration config)
24
        {
25
            _config     = config;
26
            _castUrl    = castUrl;
27
        }
28

  
29
        public NetSparkleAppCastItem GetLatestVersion()
30
        {
31
            NetSparkleAppCastItem latestVersion = null;
32
          
33
            // build a http web request stream
34
            WebRequest request = HttpWebRequest.Create(_castUrl);
35

  
36
            // request the cast and build the stream
37
            WebResponse response = request.GetResponse();
38

  
39
            Stream inputstream = response.GetResponseStream();
40

  
41
            NetSparkleAppCastItem currentItem = null;
42

  
43
            XmlTextReader reader = new XmlTextReader(inputstream);
44
            while(reader.Read())
45
            {
46
                if ( reader.NodeType == XmlNodeType.Element)
47
                {
48
                    switch(reader.Name)
49
                    {
50
                        case itemNode:
51
                            {
52
                                currentItem = new NetSparkleAppCastItem();
53
                                break;
54
                            }
55
                        case releaseNotesLinkNode:
56
                            {
57
                                currentItem.ReleaseNotesLink = reader.ReadString();
58
                                currentItem.ReleaseNotesLink = currentItem.ReleaseNotesLink.Trim('\n');
59
                                break;
60
                            }                            
61
                        case enclosureNode:
62
                            {
63
                                currentItem.Version = reader.GetAttribute(versionAttribute);
64
                                currentItem.DownloadLink = reader.GetAttribute(urlAttribute);
65
                                currentItem.DSASignature = reader.GetAttribute(dasSignature);
66

  
67
                                break;
68
                            }
69
                    }
70
                }
71
                else if (reader.NodeType == XmlNodeType.EndElement)
72
                {
73
                    switch (reader.Name)
74
                    {
75
                        case itemNode:
76
                            {
77
                                if (latestVersion == null)
78
                                    latestVersion = currentItem;
79
                                else if (currentItem.CompareTo(latestVersion) > 0 )
80
                                {
81
                                        latestVersion = currentItem;
82
                                }
83
                                break;
84
                            }                            
85
                    }
86
                }                    
87
            }
88

  
89
            // add some other attributes
90
            latestVersion.AppName = _config.ApplicationName;
91
            latestVersion.AppVersionInstalled = _config.InstalledVersion;
92
            
93
            // go ahead
94
            return latestVersion;
95
        }
96
            
97
    }
98
}
b/trunk/NetSparkle/NetSparkleAssemblyAccessor.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Reflection;
6
using System.IO;
7
using AppLimit.NetSparkle.Interfaces;
8

  
9
namespace AppLimit.NetSparkle
10
{
11
    public class NetSparkleAssemblyAccessor : INetSparkleAssemblyAccessor
12
    {
13
        INetSparkleAssemblyAccessor _internalAccessor = null;
14

  
15
        public NetSparkleAssemblyAccessor(String assemblyName, Boolean bUseReflectionAccesor)
16
        {
17
            if ( bUseReflectionAccesor )
18
                _internalAccessor = new NetSparkleAssemblyReflectionAccessor(assemblyName);
19
            else
20
                _internalAccessor = new NetSparkleAssemblyDiagnosticsAccessor(assemblyName);
21
        }
22

  
23
        #region INetSparkleAssemblyAccessor Members
24

  
25
        public string AssemblyCompany
26
        {
27
            get { return _internalAccessor.AssemblyCompany; }
28
        }
29

  
30
        public string AssemblyCopyright
31
        {
32
            get { return _internalAccessor.AssemblyCopyright; }
33
        }
34

  
35
        public string AssemblyDescription
36
        {
37
            get { return _internalAccessor.AssemblyDescription; }
38
        }
39

  
40
        public string AssemblyProduct
41
        {
42
            get { return _internalAccessor.AssemblyProduct; }
43
        }
44

  
45
        public string AssemblyTitle
46
        {
47
            get { return _internalAccessor.AssemblyTitle; }
48
        }
49

  
50
        public string AssemblyVersion
51
        {
52
            get { return _internalAccessor.AssemblyVersion; }
53
        }
54

  
55
        #endregion
56
    }
57
}
b/trunk/NetSparkle/NetSparkleAssemblyDiagnosticsAccessor.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Diagnostics;
4
using System.Linq;
5
using System.Text;
6
using System.Reflection;
7
using System.IO;
8
using AppLimit.NetSparkle.Interfaces;
9

  
10
namespace AppLimit.NetSparkle
11
{
12
    public class NetSparkleAssemblyDiagnosticsAccessor : INetSparkleAssemblyAccessor
13
    {
14
        private string fileVersion;
15
        private string productVersion;
16
        private string productName;
17
        private string companyName;
18
        private string legalCopyright;
19
        private string fileDescription;
20

  
21
        public NetSparkleAssemblyDiagnosticsAccessor(String assemblyName)
22
        {
23
            if (assemblyName != null)
24
            {
25
                fileVersion = FileVersionInfo.GetVersionInfo(assemblyName).FileVersion;
26
                productVersion = FileVersionInfo.GetVersionInfo(assemblyName).ProductVersion;
27
                productName = FileVersionInfo.GetVersionInfo(assemblyName).ProductName;
28
                companyName = FileVersionInfo.GetVersionInfo(assemblyName).CompanyName;
29
                legalCopyright = FileVersionInfo.GetVersionInfo(assemblyName).LegalCopyright;
30
                fileDescription = FileVersionInfo.GetVersionInfo(assemblyName).FileDescription; 
31
            }
32
        }
33

  
34
        #region Assembly Attribute Accessors
35

  
36
        public string AssemblyTitle
37
        {
38
            get
39
            {
40
                return productName;                
41
            }
42
        }
43

  
44
        public string AssemblyVersion
45
        {
46
            get
47
            {
48
                return fileVersion;
49
            }
50
        }        
51

  
52
        public string AssemblyDescription
53
        {
54
            get { return fileDescription; }
55
        }
56

  
57
        public string AssemblyProduct
58
        {
59
            get
60
            {
61
                return productVersion;                                
62
            }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff