Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[3047ce]: src / guixmld.cpp Maximize Restore History

Download this file

guixmld.cpp    130 lines (118 with data), 3.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 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
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
* guixmld.cpp
*
* $Id$
*
* Written by Keith Marshall <keithmarshall@users.sourceforge.net>
* Copyright (C) 2012, MinGW Project
*
*
* Implementation of XML data loading services for the mingw-get GUI.
*
*
* This is free software. Permission is granted to copy, modify and
* redistribute this software, under the provisions of the GNU General
* Public License, Version 3, (or, at your option, any later version),
* as published by the Free Software Foundation; see the file COPYING
* for licensing details.
*
* Note, in particular, that this software is provided "as is", in the
* hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
* even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
* PARTICULAR PURPOSE. Under no circumstances will the author, or the
* MinGW Project, accept liability for any damages, however caused,
* arising from the use of this software.
*
*/
#include "guimain.h"
#include "pkgbase.h"
#include "pkgkeys.h"
#include <unistd.h>
#include <wtkexcept.h>
int AppWindowMaker::Invoked( void )
{
/* Override for the WTK::MainWindowMaker::Invoked() method; it
* provides the hook for the initial loading of the XML database,
* and creation of the display controls through which its content
* will be presented to the user, prior to invocation of the main
* window's message loop.
*
* The data displays depend on the MS-Windows Common Controls API;
* initialise all components of this up front.
*/
InitCommonControls();
/* Load the data from the XML catalogue files, and construct the
* initial view of the available package list.
*/
LoadPackageData();
InitPackageListView();
/* Force a layout adjustment, to ensure that the displayed
* data controls are correctly populated.
*/
AdjustLayout();
/* Finally, we may delegate all further processing to the main
* window's message loop.
*/
return WTK::MainWindowMaker::Invoked();
}
void AppWindowMaker::LoadPackageData( bool force_update )
{
/* Helper method to load the package database from its
* defining collection of XML catalogue files.
*/
const char *dfile;
if( pkgData == NULL )
{
/* This is the first request to load the database;
* establish the load starting point as "profile.xml",
* if available...
*/
if( access( dfile = xmlfile( profile_key ), R_OK ) != 0 )
{
/* ...or as "defaults.xml" otherwise.
*/
free( (void *)(dfile) );
dfile = xmlfile( defaults_key );
}
}
else
{
/* This is a reload request; in this case we adopt the
* starting point as established for the initial load...
*/
dfile = strdup( pkgData->Value() );
/*
* ...and clear out all stale data from the previous
* time of loading.
*/
delete pkgData;
}
/* Commence loading...
*/
if( ! (pkgData = new pkgXmlDocument( dfile ))->IsOk() )
/*
* ...bailing out on failure to access the initial file.
*/
throw WTK::runtime_error( WTK::error_text(
"%s: cannot open package database", dfile
));
/* Once the initial file has been loaded, its name is
* recorded within the XML data image itself; thus, we
* may release the heap memory used to establish it
* prior to opening the file.
*/
free( (void *)(dfile) );
/* Establish the repository URI references, for retrieval
* of the downloadable catalogue files, and load them...
*/
if( pkgData->BindRepositories( force_update ) == NULL )
/*
* ...once again, bailing out on failure.
*/
throw WTK::runtime_error( "Cannot read package catalogue" );
/* Finally, load the installation records pertaining to
* the active system map.
*/
pkgData->LoadSystemMap();
}
/* $RCSfile$: end of file */