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

@ -5,5 +5,4 @@ WARNING: This is still pre-alfa software you can't do much with it yet.
This is the online help. You can show it at any time by clicking on the the Questionmark Icon above.
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++)
{
buffer[i] = getc(file);
if(!buffer[i]) break;
if(buffer[i]==EOF) break;
}
buffer[i] = 0;
SetText(buffer);
}
@ -245,9 +246,12 @@ int SetText (const char* text)
{
buffer[j] = text[i];
if(buffer[j] == '\n')
buffer[++j] = '\r';
{
buffer[j] = '\r';
buffer[++j] = '\n';
}
}
buffer[i] = 0;
buffer[j] = 0;
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 <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(
LPUNKNOWN pCaller,
LPCSTR szURL,
@ -29,11 +26,16 @@ HRESULT WINAPI URLDownloadToFileA(
int FindCount (string What, string Where, int start = 0, int end = -1);
// Download a file
char* PML_Download (const char* url, const char* server = "tree", const char* filename = NULL)
// Download a file
char* PML_Download (pTree tree, const char* url, const char* server = "tree", const char* filename = NULL)
{
char downl [MAX_PATH];
static char path [MAX_PATH];
UINT i;
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
if(!filename)
@ -52,18 +54,42 @@ char* PML_Download (const char* url, const char* server = "tree", const char* fi
GetTempFileNameA (path, "pml", 0, path);
// get the url
if (!server)
strcpy(downl, "");
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
strcpy(downl, server);
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
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
int PML_XmlDownload (const char* url, void* usrdata, XML_StartElementHandler start,
XML_EndElementHandler end, XML_CharacterDataHandler text)
int PML_XmlDownload (pTree tree, const char* url, void* usrdata,
XML_StartElementHandler start, XML_EndElementHandler end, XML_CharacterDataHandler text)
{
char buffer[255];
int done = 0;
char buffer[255];
char* filename = 0;
// logging
Log("* prozess the xml file: ");
LogAdd(url);
// 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)
{
@ -100,7 +132,9 @@ int PML_XmlDownload (const char* url, void* usrdata, XML_StartElementHandler sta
FILE* file = fopen(filename, "r");
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;
}

View file

@ -15,7 +15,7 @@
#include "log.h"
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[])
@ -31,10 +31,10 @@ int download (int argc, char* argv[])
char* result;
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)
result = PML_Download(argv[1], NULL, argv[2]);
result = PML_Download(NULL, argv[1], NULL, argv[2]);
else
return ERR_GENERIC;

View file

@ -19,7 +19,7 @@
HANDLE hThread = NULL;
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
@ -47,7 +47,7 @@ DWORD WINAPI DoitThread (void* lpParam)
{
SCRIPT* script;
char* path = PML_Download(tree->todo[i]);
char* path = PML_Download(tree, tree->todo[i]);
if(RPS_Load(&script, path) == ERR_OK)
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_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

View file

@ -14,8 +14,8 @@
#include "expat.h"
#include "log.h"
int PML_XmlDownload (const char* url, void* usrdata, XML_StartElementHandler start,
XML_EndElementHandler end, XML_CharacterDataHandler text=0);
int PML_XmlDownload (pTree, const char* url, void* usrdata, XML_StartElementHandler start,
XML_EndElementHandler end, XML_CharacterDataHandler text=0);
// expat callback for start of a package tag
@ -109,7 +109,7 @@ extern "C" int PML_LoadPackage (TREE* tree, int id, PML_SetButton SetButton)
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;
}
@ -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
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;
return PML_SetAction(tree, id, action, SetIcon, Ask);
@ -262,17 +262,17 @@ 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
if(!pack->path || pack->action==0)
return ret;
// erase from todo list
for(i=0; i<tree->todo.size(); i++)
if(!strcmp(tree->todo[i], pack->files[pack->action-1])) // look for right entry
tree->todo.erase(tree->todo.begin()+i); // delete it
// set action back
pack->action = 0;
}
return ret;

View file

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

View file

@ -15,11 +15,13 @@
vector <int> parents;
int LoadOptions (TREE* tree);
void tree_end (void* tree, const char* tag);
void tree_start (void* usrdata, const char* tag, const char** arg);
int PML_XmlDownload (const char* file, void* usrdata, XML_StartElementHandler start,
XML_EndElementHandler end, XML_CharacterDataHandler text=0);
int PML_XmlDownload (pTree tree, const char* file, void* usrdata, XML_StartElementHandler start,
XML_EndElementHandler end, XML_CharacterDataHandler text=0);
// Load the tree
@ -34,7 +36,9 @@ extern "C" int PML_LoadTree (TREE** tree, char* url, PML_AddItem AddItem)
// set addItem callback
(*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
@ -119,3 +123,4 @@ void tree_end (void* tree, const char* tag)
// delete last item
parents.pop_back();
}