PackageManager: Options.xml
authorMaarten Bosma <maarten@bosma.de>
Wed, 20 Apr 2005 19:01:30 +0000 (19:01 +0000)
committerMaarten Bosma <maarten@bosma.de>
Wed, 20 Apr 2005 19:01:30 +0000 (19:01 +0000)
svn path=/trunk/; revision=14718

rosapps/packmgr/cmd-line/options.xml [new file with mode: 0644]
rosapps/packmgr/gui/help.txt [moved from rosapps/packmgr/help.txt with 96% similarity]
rosapps/packmgr/gui/main.c
rosapps/packmgr/gui/options.xml [new file with mode: 0644]
rosapps/packmgr/lib/download.cpp
rosapps/packmgr/lib/functions.cpp
rosapps/packmgr/lib/main.cpp
rosapps/packmgr/lib/makefile
rosapps/packmgr/lib/package.cpp
rosapps/packmgr/lib/package.hpp
rosapps/packmgr/lib/tree.cpp

diff --git a/rosapps/packmgr/cmd-line/options.xml b/rosapps/packmgr/cmd-line/options.xml
new file mode 100644 (file)
index 0000000..71ea7af
--- /dev/null
@@ -0,0 +1,4 @@
+<options>\r
+  <source>file://C:\Programmieren\reactos\rosapps\packmgr\tree\</source>\r
+  <source>http://svn.reactos.com/viewcvs/*checkout*/trunk/rosapps/packmgr/tree/</source>\r
+</options>
\ No newline at end of file
similarity index 96%
rename from rosapps/packmgr/help.txt
rename to rosapps/packmgr/gui/help.txt
index c6de41b..846682d 100644 (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.\r
 \r
 You can use this package manager like this: click on the \r
-You can also use the Buttons [ctrl] + [0] to [4] to set the action.\r
-\r
+You can also use the Buttons [ctrl] + [0] to [4] to set the action.
\ No newline at end of file
index 5cfe8eb..727bfc1 100644 (file)
@@ -121,8 +121,9 @@ void Help (void)
        for(i=0; i<2000; i++)\r
        {\r
                buffer[i] = getc(file);\r
-               if(!buffer[i]) break;\r
+               if(buffer[i]==EOF) break;\r
        }\r
+       buffer[i] = 0;\r
 \r
        SetText(buffer);\r
 }\r
@@ -245,9 +246,12 @@ int SetText (const char* text)
        {\r
                buffer[j] = text[i];\r
                if(buffer[j] == '\n')\r
-                       buffer[++j] = '\r';\r
+               {\r
+                       buffer[j] = '\r';\r
+                       buffer[++j] = '\n';\r
+               }\r
        }\r
-       buffer[i] = 0;\r
+       buffer[j] = 0;\r
 \r
        SetWindowTextA(hEdit, buffer);\r
 \r
diff --git a/rosapps/packmgr/gui/options.xml b/rosapps/packmgr/gui/options.xml
new file mode 100644 (file)
index 0000000..71ea7af
--- /dev/null
@@ -0,0 +1,4 @@
+<options>\r
+  <source>file://C:\Programmieren\reactos\rosapps\packmgr\tree\</source>\r
+  <source>http://svn.reactos.com/viewcvs/*checkout*/trunk/rosapps/packmgr/tree/</source>\r
+</options>
\ No newline at end of file
index 51ab771..41761dd 100644 (file)
@@ -15,9 +15,6 @@
 #include "log.h"\r
 #include <wine/urlmon.h>\r
 \r
-// Server there all the files lie\r
-const char* tree_server = "http://svn.reactos.com/viewcvs/*checkout*/trunk/rosapps/packmgr/tree/"; \r
-\r
 HRESULT WINAPI URLDownloadToFileA(      \r
     LPUNKNOWN pCaller,\r
     LPCSTR szURL,\r
@@ -29,11 +26,16 @@ HRESULT WINAPI URLDownloadToFileA(
 int FindCount (string What, string Where, int start = 0, int end = -1);\r
 \r
 \r
-// Download a file\r
-char* PML_Download (const char* url, const char* server = "tree", const char* filename = NULL) \r
+// Download a file \r
+char* PML_Download (pTree tree, const char* url, const char* server = "tree", const char* filename = NULL) \r
 {\r
-       char downl [MAX_PATH];\r
-       static char path [MAX_PATH];\r
+       UINT i;\r
+       static char downl [MAX_PATH]; // the full url\r
+       static char path [MAX_PATH]; // the full resulting Path\r
+\r
+       // It goes to the temp folder when no other path is entered (or even compleatly no filename)\r
+       // If server == "tree" it will be downloaded from the server speficied in option.xml\r
+       // File:// links are possible too\r
 \r
        // get temp dir\r
        if(!filename)\r
@@ -52,18 +54,42 @@ char* PML_Download (const char* url, const char* server = "tree", const char* fi
                GetTempFileNameA (path, "pml", 0, path); \r
 \r
        // get the url\r
-       \r
        if (!server)\r
                strcpy(downl, "");\r
 \r
        else if(!strcmp(server, "tree")) \r
-               strcpy(downl, tree_server);\r
+       {\r
+               char* ret;\r
+               for (i=0; i<tree->sources.size(); i++)\r
+               {\r
+                       ret = PML_Download(tree, url, tree->sources[i], filename);\r
+                       if(ret)\r
+                               return ret;\r
+               }\r
+               return NULL;\r
+       }\r
 \r
        else \r
                strcpy(downl, server);\r
 \r
        strcat(downl, url);\r
 \r
+       // is this a file link ?\r
+       if (strstr(downl, "file://") || strstr(downl, "File://"))\r
+       {/*\r
+               if(downl[strlen(downl)] == '\')\r
+                       downl[strlen(downl)] = '\0';\r
+       */\r
+               if(!filename)\r
+                       return &downl[7];\r
+\r
+               else\r
+               {\r
+                       CopyFileA(filename, &downl[7], FALSE);\r
+                       return (char*)filename;\r
+               }\r
+       }\r
+\r
        // download the file\r
        if(URLDownloadToFileA (NULL, downl, path, 0, NULL) != S_OK)\r
        {\r
@@ -77,18 +103,24 @@ char* PML_Download (const char* url, const char* server = "tree", const char* fi
 }\r
 \r
 // Download and prozess a xml file\r
-int PML_XmlDownload (const char* url, void* usrdata, XML_StartElementHandler start, \r
-                                                XML_EndElementHandler end, XML_CharacterDataHandler text) \r
+int PML_XmlDownload (pTree tree, const char* url, void* usrdata,\r
+                                                XML_StartElementHandler start, XML_EndElementHandler end, XML_CharacterDataHandler text) \r
 {\r
-       char buffer[255];\r
        int done = 0;\r
+       char buffer[255];\r
+       char* filename = 0;\r
 \r
        // logging\r
        Log("*  prozess the xml file: ");\r
        LogAdd(url);\r
 \r
        // download the file\r
-       char* filename = PML_Download(url);\r
+       if(strstr(url, "file://"))\r
+               filename = PML_Download(tree, url, NULL);\r
+\r
+       else\r
+               filename = PML_Download(tree, url);\r
+\r
 \r
        if(!filename) \r
        {\r
@@ -100,7 +132,9 @@ int PML_XmlDownload (const char* url, void* usrdata, XML_StartElementHandler sta
        FILE* file = fopen(filename, "r");\r
        if(!file) \r
        {\r
-               Log("!  ERROR: Could not open the xml file");\r
+       MessageBoxA(0,filename,0,0);\r
+               Log("!  ERROR: Could not open the xml file \"");\r
+               LogAdd(filename);\r
                return ERR_GENERIC;\r
        }\r
 \r
index ff6f137..a73d0ce 100644 (file)
@@ -15,7 +15,7 @@
 #include "log.h"\r
 \r
 extern const char* tree_server;\r
-char* PML_Download (const char* url, const char* server,  const char* filename);\r
+char* PML_Download (pTree, const char* url, const char* server,  const char* filename);\r
 \r
 \r
 int debuglog (int argc, char* argv[])\r
@@ -31,10 +31,10 @@ int download (int argc, char* argv[])
        char* result;\r
 \r
        if (argc==3)\r
-               result = PML_Download(argv[1], argv[3], argv[2]);\r
+               result = PML_Download(NULL, argv[1], argv[3], argv[2]);\r
 \r
        else if (argc==2)\r
-               result = PML_Download(argv[1], NULL, argv[2]);\r
+               result = PML_Download(NULL, argv[1], NULL, argv[2]);\r
 \r
        else \r
                return ERR_GENERIC;\r
index 6463e05..f18d292 100644 (file)
@@ -19,7 +19,7 @@
 HANDLE hThread = NULL;\r
 BOOL thread_abort = FALSE;\r
 \r
-char* PML_Download (const char* url, const char* server = "tree",  const char* filename = NULL);\r
+char* PML_Download (pTree, const char* url, const char* server = "tree",  const char* filename = NULL);\r
 \r
 \r
 // Abort other thread\r
@@ -47,7 +47,7 @@ DWORD WINAPI DoitThread (void* lpParam)
        {\r
                SCRIPT* script;\r
 \r
-               char* path = PML_Download(tree->todo[i]);\r
+               char* path = PML_Download(tree, tree->todo[i]);\r
 \r
                if(RPS_Load(&script, path) == ERR_OK)\r
                        scripts.push_back(script);\r
index a0d153b..c9ef7ba 100644 (file)
@@ -6,7 +6,7 @@ TARGET_INSTALLDIR = bin
 \r
 TARGET_SDKLIBS = kernel32.a shell32.a user32.a package.a expat.a urlmon.a\r
 \r
-TARGET_OBJECTS = main.o tree.o package.o download.o script.o functions.o log.o\r
+TARGET_OBJECTS = main.o tree.o package.o download.o script.o functions.o options.o log.o\r
 \r
 TARGET_GCCLIBS = stdc++ uuid\r
 \r
index 883be31..c545756 100644 (file)
@@ -14,8 +14,8 @@
 #include "expat.h"\r
 #include "log.h"\r
 \r
-int PML_XmlDownload (const char* url, void* usrdata, XML_StartElementHandler start, \r
-                                        XML_EndElementHandler end, XML_CharacterDataHandler text=0);\r
+int PML_XmlDownload (pTree, const char* url, void* usrdata, XML_StartElementHandler start, \r
+                                                                       XML_EndElementHandler end, XML_CharacterDataHandler text=0);\r
 \r
 \r
 // expat callback for start of a package tag\r
@@ -109,7 +109,7 @@ extern "C" int PML_LoadPackage (TREE* tree, int id, PML_SetButton SetButton)
 \r
        if(!pack->loaded)\r
        {\r
-               PML_XmlDownload (pack->path, (void*)pack, pack_start, pack_end, pack_text);\r
+               PML_XmlDownload (tree, pack->path, (void*)pack, pack_start, pack_end, pack_text);\r
                pack->loaded = TRUE;\r
        }\r
 \r
@@ -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\r
        else if (!pack->loaded && pack->path)\r
        {\r
-               PML_XmlDownload (pack->path, (void*)pack, pack_start, pack_end, pack_text);\r
+               PML_XmlDownload (tree, pack->path, (void*)pack, pack_start, pack_end, pack_text);\r
                pack->loaded = TRUE;\r
 \r
                return PML_SetAction(tree, id, action, SetIcon, Ask);\r
@@ -262,17 +262,17 @@ extern "C" int PML_SetAction (TREE* tree, int id, int action, PML_SetIcon SetIco
                        }\r
                }\r
 \r
-               // set action back\r
-               pack->action = 0;\r
-\r
                // root notes (like network) return here\r
                if(!pack->path || pack->action==0)\r
                        return ret; \r
-       \r
+\r
                // erase from todo list\r
                for(i=0; i<tree->todo.size(); i++)\r
                        if(!strcmp(tree->todo[i], pack->files[pack->action-1])) // look for right entry\r
                                tree->todo.erase(tree->todo.begin()+i); // delete it\r
+\r
+               // set action back\r
+               pack->action = 0;\r
        }\r
 \r
        return ret;\r
index 1170ba4..0447317 100644 (file)
@@ -26,15 +26,15 @@ typedef int (*PML_Ask)                      (const WCHAR* text);
 typedef struct\r
 {\r
   char*                        path;\r
+  char*                        name;\r
+  char*                        description;\r
+  char**               field;\r
+\r
   BOOL                 icon;\r
   BOOL                 loaded;\r
+  vector<int>  neededBy;\r
   vector<int>  children;\r
-\r
-  char**               field;\r
-  char*                        name;\r
-  char*                        description;\r
   vector<char*>        depencies;\r
-  vector<int>  neededBy;\r
   \r
   int                  action;\r
   char*                        files [4];\r
@@ -49,10 +49,11 @@ typedef struct
 \r
 typedef struct\r
 {\r
-  char*                                xmltree;\r
+  char**               field;\r
 \r
-  vector<char*>                descriptionPath;\r
   vector<char*>                todo;\r
+  vector<char*>                sources;\r
+  vector<char*>                descriptionPath;\r
   vector<PACKAGE>      packages;\r
 \r
   PML_AddItem          addItem;\r
index 00d27a8..867a74b 100644 (file)
 \r
 vector <int> parents;\r
 \r
+int LoadOptions (TREE* tree);\r
+\r
 void tree_end (void* tree, const char* tag);\r
 void tree_start (void* usrdata, const char* tag, const char** arg);\r
 \r
-int PML_XmlDownload (const char* file, void* usrdata, XML_StartElementHandler start, \r
-                                        XML_EndElementHandler end, XML_CharacterDataHandler text=0);\r
+int PML_XmlDownload (pTree tree, const char* file, void* usrdata, XML_StartElementHandler start, \r
+                                                                                       XML_EndElementHandler end, XML_CharacterDataHandler text=0);\r
 \r
 \r
 // Load the tree\r
@@ -34,7 +36,9 @@ extern "C" int PML_LoadTree (TREE** tree, char* url, PML_AddItem AddItem)
        // set addItem callback\r
        (*tree)->addItem = AddItem;\r
 \r
-       return PML_XmlDownload (url, (void*)(*tree), tree_start, tree_end);\r
+       LoadOptions(*tree);\r
+\r
+       return PML_XmlDownload (*tree, url, (void*)(*tree), tree_start, tree_end);\r
 }\r
 \r
 // expat callback for start of a "node" tag\r
@@ -119,3 +123,4 @@ void tree_end (void* tree, const char* tag)
        // delete last item\r
        parents.pop_back();\r
 }\r
+\r