PackageManager: Options.xml

svn path=/trunk/; revision=14718
This commit is contained in:
Maarten Bosma 2005-04-20 19:01:30 +00:00
parent 31390cae28
commit 31d0c28c6d
11 changed files with 95 additions and 44 deletions

View file

@ -0,0 +1,4 @@
<options>
<source>file://C:\Programmieren\reactos\rosapps\packmgr\tree\</source>
<source>http://svn.reactos.com/viewcvs/*checkout*/trunk/rosapps/packmgr/tree/</source>
</options>

View file

@ -6,4 +6,3 @@ This is the online help. You can show it at any time by clicking on the the Ques
You can use this package manager like this: click on the You can use this package manager like this: click on the
You can also use the Buttons [ctrl] + [0] to [4] to set the action. You can also use the Buttons [ctrl] + [0] to [4] to set the action.

View file

@ -121,8 +121,9 @@ void Help (void)
for(i=0; i<2000; i++) for(i=0; i<2000; i++)
{ {
buffer[i] = getc(file); buffer[i] = getc(file);
if(!buffer[i]) break; if(buffer[i]==EOF) break;
} }
buffer[i] = 0;
SetText(buffer); SetText(buffer);
} }
@ -245,9 +246,12 @@ int SetText (const char* text)
{ {
buffer[j] = text[i]; buffer[j] = text[i];
if(buffer[j] == '\n') if(buffer[j] == '\n')
buffer[++j] = '\r'; {
buffer[j] = '\r';
buffer[++j] = '\n';
} }
buffer[i] = 0; }
buffer[j] = 0;
SetWindowTextA(hEdit, buffer); SetWindowTextA(hEdit, buffer);

View file

@ -0,0 +1,4 @@
<options>
<source>file://C:\Programmieren\reactos\rosapps\packmgr\tree\</source>
<source>http://svn.reactos.com/viewcvs/*checkout*/trunk/rosapps/packmgr/tree/</source>
</options>

View file

@ -15,9 +15,6 @@
#include "log.h" #include "log.h"
#include <wine/urlmon.h> #include <wine/urlmon.h>
// Server there all the files lie
const char* tree_server = "http://svn.reactos.com/viewcvs/*checkout*/trunk/rosapps/packmgr/tree/";
HRESULT WINAPI URLDownloadToFileA( HRESULT WINAPI URLDownloadToFileA(
LPUNKNOWN pCaller, LPUNKNOWN pCaller,
LPCSTR szURL, LPCSTR szURL,
@ -30,10 +27,15 @@ int FindCount (string What, string Where, int start = 0, int end = -1);
// Download a file // Download a file
char* PML_Download (const char* url, const char* server = "tree", const char* filename = NULL) char* PML_Download (pTree tree, const char* url, const char* server = "tree", const char* filename = NULL)
{ {
char downl [MAX_PATH]; UINT i;
static char path [MAX_PATH]; static char downl [MAX_PATH]; // the full url
static char path [MAX_PATH]; // the full resulting Path
// It goes to the temp folder when no other path is entered (or even compleatly no filename)
// If server == "tree" it will be downloaded from the server speficied in option.xml
// File:// links are possible too
// get temp dir // get temp dir
if(!filename) if(!filename)
@ -52,18 +54,42 @@ char* PML_Download (const char* url, const char* server = "tree", const char* fi
GetTempFileNameA (path, "pml", 0, path); GetTempFileNameA (path, "pml", 0, path);
// get the url // get the url
if (!server) if (!server)
strcpy(downl, ""); strcpy(downl, "");
else if(!strcmp(server, "tree")) else if(!strcmp(server, "tree"))
strcpy(downl, tree_server); {
char* ret;
for (i=0; i<tree->sources.size(); i++)
{
ret = PML_Download(tree, url, tree->sources[i], filename);
if(ret)
return ret;
}
return NULL;
}
else else
strcpy(downl, server); strcpy(downl, server);
strcat(downl, url); strcat(downl, url);
// is this a file link ?
if (strstr(downl, "file://") || strstr(downl, "File://"))
{/*
if(downl[strlen(downl)] == '\')
downl[strlen(downl)] = '\0';
*/
if(!filename)
return &downl[7];
else
{
CopyFileA(filename, &downl[7], FALSE);
return (char*)filename;
}
}
// download the file // download the file
if(URLDownloadToFileA (NULL, downl, path, 0, NULL) != S_OK) if(URLDownloadToFileA (NULL, downl, path, 0, NULL) != S_OK)
{ {
@ -77,18 +103,24 @@ char* PML_Download (const char* url, const char* server = "tree", const char* fi
} }
// Download and prozess a xml file // Download and prozess a xml file
int PML_XmlDownload (const char* url, void* usrdata, XML_StartElementHandler start, int PML_XmlDownload (pTree tree, const char* url, void* usrdata,
XML_EndElementHandler end, XML_CharacterDataHandler text) XML_StartElementHandler start, XML_EndElementHandler end, XML_CharacterDataHandler text)
{ {
char buffer[255];
int done = 0; int done = 0;
char buffer[255];
char* filename = 0;
// logging // logging
Log("* prozess the xml file: "); Log("* prozess the xml file: ");
LogAdd(url); LogAdd(url);
// download the file // download the file
char* filename = PML_Download(url); if(strstr(url, "file://"))
filename = PML_Download(tree, url, NULL);
else
filename = PML_Download(tree, url);
if(!filename) if(!filename)
{ {
@ -100,7 +132,9 @@ int PML_XmlDownload (const char* url, void* usrdata, XML_StartElementHandler sta
FILE* file = fopen(filename, "r"); FILE* file = fopen(filename, "r");
if(!file) if(!file)
{ {
Log("! ERROR: Could not open the xml file"); MessageBoxA(0,filename,0,0);
Log("! ERROR: Could not open the xml file \"");
LogAdd(filename);
return ERR_GENERIC; return ERR_GENERIC;
} }

View file

@ -15,7 +15,7 @@
#include "log.h" #include "log.h"
extern const char* tree_server; extern const char* tree_server;
char* PML_Download (const char* url, const char* server, const char* filename); char* PML_Download (pTree, const char* url, const char* server, const char* filename);
int debuglog (int argc, char* argv[]) int debuglog (int argc, char* argv[])
@ -31,10 +31,10 @@ int download (int argc, char* argv[])
char* result; char* result;
if (argc==3) if (argc==3)
result = PML_Download(argv[1], argv[3], argv[2]); result = PML_Download(NULL, argv[1], argv[3], argv[2]);
else if (argc==2) else if (argc==2)
result = PML_Download(argv[1], NULL, argv[2]); result = PML_Download(NULL, argv[1], NULL, argv[2]);
else else
return ERR_GENERIC; return ERR_GENERIC;

View file

@ -19,7 +19,7 @@
HANDLE hThread = NULL; HANDLE hThread = NULL;
BOOL thread_abort = FALSE; BOOL thread_abort = FALSE;
char* PML_Download (const char* url, const char* server = "tree", const char* filename = NULL); char* PML_Download (pTree, const char* url, const char* server = "tree", const char* filename = NULL);
// Abort other thread // Abort other thread
@ -47,7 +47,7 @@ DWORD WINAPI DoitThread (void* lpParam)
{ {
SCRIPT* script; SCRIPT* script;
char* path = PML_Download(tree->todo[i]); char* path = PML_Download(tree, tree->todo[i]);
if(RPS_Load(&script, path) == ERR_OK) if(RPS_Load(&script, path) == ERR_OK)
scripts.push_back(script); scripts.push_back(script);

View file

@ -6,7 +6,7 @@ TARGET_INSTALLDIR = bin
TARGET_SDKLIBS = kernel32.a shell32.a user32.a package.a expat.a urlmon.a TARGET_SDKLIBS = kernel32.a shell32.a user32.a package.a expat.a urlmon.a
TARGET_OBJECTS = main.o tree.o package.o download.o script.o functions.o log.o TARGET_OBJECTS = main.o tree.o package.o download.o script.o functions.o options.o log.o
TARGET_GCCLIBS = stdc++ uuid TARGET_GCCLIBS = stdc++ uuid

View file

@ -14,7 +14,7 @@
#include "expat.h" #include "expat.h"
#include "log.h" #include "log.h"
int PML_XmlDownload (const char* url, void* usrdata, XML_StartElementHandler start, int PML_XmlDownload (pTree, const char* url, void* usrdata, XML_StartElementHandler start,
XML_EndElementHandler end, XML_CharacterDataHandler text=0); XML_EndElementHandler end, XML_CharacterDataHandler text=0);
@ -109,7 +109,7 @@ extern "C" int PML_LoadPackage (TREE* tree, int id, PML_SetButton SetButton)
if(!pack->loaded) if(!pack->loaded)
{ {
PML_XmlDownload (pack->path, (void*)pack, pack_start, pack_end, pack_text); PML_XmlDownload (tree, pack->path, (void*)pack, pack_start, pack_end, pack_text);
pack->loaded = TRUE; pack->loaded = TRUE;
} }
@ -208,7 +208,7 @@ extern "C" int PML_SetAction (TREE* tree, int id, int action, PML_SetIcon SetIco
// load it if it's not loaded yet // load it if it's not loaded yet
else if (!pack->loaded && pack->path) else if (!pack->loaded && pack->path)
{ {
PML_XmlDownload (pack->path, (void*)pack, pack_start, pack_end, pack_text); PML_XmlDownload (tree, pack->path, (void*)pack, pack_start, pack_end, pack_text);
pack->loaded = TRUE; pack->loaded = TRUE;
return PML_SetAction(tree, id, action, SetIcon, Ask); return PML_SetAction(tree, id, action, SetIcon, Ask);
@ -262,9 +262,6 @@ extern "C" int PML_SetAction (TREE* tree, int id, int action, PML_SetIcon SetIco
} }
} }
// set action back
pack->action = 0;
// root notes (like network) return here // root notes (like network) return here
if(!pack->path || pack->action==0) if(!pack->path || pack->action==0)
return ret; return ret;
@ -273,6 +270,9 @@ extern "C" int PML_SetAction (TREE* tree, int id, int action, PML_SetIcon SetIco
for(i=0; i<tree->todo.size(); i++) for(i=0; i<tree->todo.size(); i++)
if(!strcmp(tree->todo[i], pack->files[pack->action-1])) // look for right entry if(!strcmp(tree->todo[i], pack->files[pack->action-1])) // look for right entry
tree->todo.erase(tree->todo.begin()+i); // delete it tree->todo.erase(tree->todo.begin()+i); // delete it
// set action back
pack->action = 0;
} }
return ret; return ret;

View file

@ -26,15 +26,15 @@ typedef int (*PML_Ask) (const WCHAR* text);
typedef struct typedef struct
{ {
char* path; char* path;
BOOL icon;
BOOL loaded;
vector<int> children;
char** field;
char* name; char* name;
char* description; char* description;
vector<char*> depencies; char** field;
BOOL icon;
BOOL loaded;
vector<int> neededBy; vector<int> neededBy;
vector<int> children;
vector<char*> depencies;
int action; int action;
char* files [4]; char* files [4];
@ -49,10 +49,11 @@ typedef struct
typedef struct typedef struct
{ {
char* xmltree; char** field;
vector<char*> descriptionPath;
vector<char*> todo; vector<char*> todo;
vector<char*> sources;
vector<char*> descriptionPath;
vector<PACKAGE> packages; vector<PACKAGE> packages;
PML_AddItem addItem; PML_AddItem addItem;

View file

@ -15,10 +15,12 @@
vector <int> parents; vector <int> parents;
int LoadOptions (TREE* tree);
void tree_end (void* tree, const char* tag); void tree_end (void* tree, const char* tag);
void tree_start (void* usrdata, const char* tag, const char** arg); void tree_start (void* usrdata, const char* tag, const char** arg);
int PML_XmlDownload (const char* file, void* usrdata, XML_StartElementHandler start, int PML_XmlDownload (pTree tree, const char* file, void* usrdata, XML_StartElementHandler start,
XML_EndElementHandler end, XML_CharacterDataHandler text=0); XML_EndElementHandler end, XML_CharacterDataHandler text=0);
@ -34,7 +36,9 @@ extern "C" int PML_LoadTree (TREE** tree, char* url, PML_AddItem AddItem)
// set addItem callback // set addItem callback
(*tree)->addItem = AddItem; (*tree)->addItem = AddItem;
return PML_XmlDownload (url, (void*)(*tree), tree_start, tree_end); LoadOptions(*tree);
return PML_XmlDownload (*tree, url, (void*)(*tree), tree_start, tree_end);
} }
// expat callback for start of a "node" tag // expat callback for start of a "node" tag
@ -119,3 +123,4 @@ void tree_end (void* tree, const char* tag)
// delete last item // delete last item
parents.pop_back(); parents.pop_back();
} }