PackageManager
Created the commandline Interface
Deleated subcategries
Added: trunk/rosapps/packmgr/cmd-line/
Added: trunk/rosapps/packmgr/cmd-line/main.cpp
Added: trunk/rosapps/packmgr/cmd-line/main.h
Added: trunk/rosapps/packmgr/cmd-line/makefile
Added: trunk/rosapps/packmgr/cmd-line/ros-get.rc
Modified: trunk/rosapps/packmgr/gui/main.cpp
Modified: trunk/rosapps/packmgr/lib/package.cpp
Modified: trunk/rosapps/packmgr/lib/package.def
Modified: trunk/rosapps/packmgr/lib/package.hpp
Modified: trunk/rosapps/packmgr/lib/tree.cpp
Modified: trunk/rosapps/packmgr/tree/tree.xml
Added: trunk/rosapps/packmgr/tree/tree_withsubs.xml
_____
Added: trunk/rosapps/packmgr/cmd-line/main.cpp
--- trunk/rosapps/packmgr/cmd-line/main.cpp 2005-04-08 19:03:04 UTC
(rev 14552)
+++ trunk/rosapps/packmgr/cmd-line/main.cpp 2005-04-08 19:09:20 UTC
(rev 14553)
@@ -0,0 +1,185 @@
+////////////////////////////////////////////////////////
+//
+// main.cpp
+//
+// Implementation of a Commandlne Interface
+// for the ReactOs Package Manager
+//
+// Maarten Bosma, 09.01.2004
+// maarten.paul(a)bosma.de
+//
+////////////////////////////////////////////////////////////////////
+
+#include "main.h"
+
+
+int main (int argc, char **argv)
+{
+ cout << "ReactOs PackageManager " << PACKMGR_VERSION_MAJOR
<<
"." << PACKMGR_VERSION_MINOR << "." <<
PACKMGR_VERSION_PATCH_LEVEL << "
Commandline Interface \n\n";
+
+ int i;
+
+ if(argc<2)
+ return Help();
+
+ for (i=1; i<argc; i++)
+ cmdline.push_back(argv[i]);
+
+ // install a package
+ if (cmdline[0] == "install")
+ Install();
+
+ // install a package from source
+ else if (cmdline[0] == "src-inst")
+ {
+ cout << "Sorry but I can't do that yet. \n";
+ }
+
+ // update a package
+ else if (cmdline[0] == "update")
+ {
+ cout << "Sorry but I can't do that yet. \n";
+ }
+
+ // update everything
+ else if (cmdline[0] == "dist-upgrade")
+ {
+ cout << "Sorry but I can't do that yet. \n";
+ }
+
+ // remove a package
+ else if (cmdline[0] == "remove")
+ {
+ cout << "Sorry but I can't do that yet. \n";
+ }
+
+ // search for a package
+ else if (cmdline[0] == "show")
+ {
+ Show();
+ }
+
+ // search for a package
+ else if (cmdline[0] == "search")
+ {
+ cout << "Sorry but I can't do that yet. \n";
+ }
+
+ else
+ Help();
+
+ return 0;
+}
+
+int Help (void)
+{
+ cout << "Usage: ros-get [command] \n\n";
+
+ cout << "Possible commands: \n";
+ cout << " install [package name] \t Installs a package \n\n";
+ cout << " show [package name] \t\t Shows you detailed
information about a package \n";
+
+ cout << "Currently unimplemented commands: \n";
+ cout << " src-install [package name] \t Installs a package from
source code \n";
+ cout << " update [package name] \t Updates a package \n";
+ cout << " dist-update [package name] \t Updates a package \n";
+ cout << " remove [package name] \t Uninstalls a package \n\n";
+
+ cout << " search [search agrument] \t Finds a package \n";
+ cout << " list \t\t\t\t Lists all installed programs \n\n";
+
+ return 0;
+}
+
+int SetStatus (int status1, int status2, WCHAR* text)
+{
+ if(text)
+ wprintf(L"%s\n", text);
+
+ // If the Status is 1000 things are done
+ if(status1==1000)
+ {
+ wprintf(L"%s\n", PML_TransError(status2));
+ done = true;
+ }
+
+ return 0;
+}
+
+int Install (void)
+{
+ pTree tree;
+ int i, error;
+
+ // load the tree
+ error = PML_LoadTree (&tree, "tree.xml", NULL);
+ if(error)
+ {
+ cout << PML_TransError(error);
+ return 0;
+ }
+
+ // look up the item
+ for (i=1; (UINT)i<cmdline.size(); i++)
+ {
+ int id = PML_FindItem(tree, cmdline[i].c_str());
+
+ if(id)
+ PML_SetAction(tree, id, 1, NULL);
+
+ else
+ cout << "Could not find the Package \"" <<
cmdline[i] << "\"\n";
+ }
+
+ // do it
+ error = PML_DoIt (tree, SetStatus);
+ if(error)
+ {
+ wprintf(L"%s\n", PML_TransError(error));
+ PML_CloseTree (tree);
+ return 0;
+ }
+
+ // wait
+ while (!done)
+ Sleep(1000);
+
+ // clean up
+ PML_CloseTree (tree);
+
+ return 0;
+}
+
+int Show (void)
+{
+ pTree tree;
+ int i, error;
+
+ // load the tree
+ error = PML_LoadTree (&tree, "tree.xml", NULL);
+ if(error)
+ {
+ cout << PML_TransError(error);
+ return 0;
+ }
+
+ // look up the item
+ for (i=1; (UINT)i<cmdline.size(); i++)
+ {
+ int id = PML_FindItem(tree, cmdline[i].c_str());
+
+ cout << i << "<" << cmdline.size() << endl;
+
+ if(id)
+ cout << PML_GetDescription (tree, id) << "\n";
+
+ else
+ cout << "Could not find the Package \"" <<
cmdline[i] << "\"\n";
+ }
+ cout << i << "<" << cmdline.size() << endl;
+
+ // clean up
+ PML_CloseTree (tree);
+
+ return 0;
+}
_____
Added: trunk/rosapps/packmgr/cmd-line/main.h
--- trunk/rosapps/packmgr/cmd-line/main.h 2005-04-08 19:03:04 UTC
(rev 14552)
+++ trunk/rosapps/packmgr/cmd-line/main.h 2005-04-08 19:09:20 UTC
(rev 14553)
@@ -0,0 +1,19 @@
+///////////////////////////////////////////////////
+//
+// main.h
+// main.cpp's lumber room :)
+///////////////////////////////////////////////////
+
+#include "package.hpp"
+
+#include <iostream>
+
+
+vector<string> cmdline;
+bool done = false;
+
+int Help (void);
+int Install (void);
+int Show (void);
+
+int SetStatus (int status1, int status2, WCHAR* text);
_____
Added: trunk/rosapps/packmgr/cmd-line/makefile
--- trunk/rosapps/packmgr/cmd-line/makefile 2005-04-08 19:03:04 UTC
(rev 14552)
+++ trunk/rosapps/packmgr/cmd-line/makefile 2005-04-08 19:09:20 UTC
(rev 14553)
@@ -0,0 +1,24 @@
+
+TARGET_NAME = ros-get
+TARGET_TYPE = program
+TARGET_APPTYPE = console
+PATH_TO_TOP = ../../../reactos
+
+TARGET_SDKLIBS = package.a
+
+TARGET_GCCLIBS = stdc++ uuid
+
+TARGET_OBJECTS = main.o
+
+TARGET_CFLAGS = \
+ -D__USE_W32API -DWIN32 -D_ROS_ \
+ -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 \
+ -DUNICODE -Wall -I../lib
+
+TARGET_CPPFLAGS = $(TARGET_CFLAGS)
+
+TARGET_RCFLAGS = -D__USE_W32API -DNDEBUG -DWIN32 -D_ROS_ -D__WINDRES__
-DUNICODE
+
+include $(PATH_TO_TOP)/rules.mak
+include $(TOOLS_PATH)/helper.mk
+include $(TOOLS_PATH)/depend.mk
_____
Added: trunk/rosapps/packmgr/cmd-line/ros-get.rc
--- trunk/rosapps/packmgr/cmd-line/ros-get.rc 2005-04-08 19:03:04 UTC
(rev 14552)
+++ trunk/rosapps/packmgr/cmd-line/ros-get.rc 2005-04-08 19:09:20 UTC
(rev 14553)
@@ -0,0 +1,8 @@
+
+#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Package Manager -
Cmdline Interface\0"
+#define REACTOS_STR_INTERNAL_NAME "ros-get\0"
+#define REACTOS_STR_ORIGINAL_FILENAME "ros-get.exe\0"
+
+#include <reactos/version.rc>
+
+/* EOF */
_____
Modified: trunk/rosapps/packmgr/gui/main.cpp
--- trunk/rosapps/packmgr/gui/main.cpp 2005-04-08 19:03:04 UTC (rev
14552)
+++ trunk/rosapps/packmgr/gui/main.cpp 2005-04-08 19:09:20 UTC (rev
14553)
@@ -204,12 +204,15 @@
SetMenuItemInfo(hPopup, id, FALSE, &mi);
- return 1;
+ return 0;
}
// Set the text of the text box
int SetText (const char* text)
{
+ if(!text)
+ return 1;
+
int i = 0;
string source = text;
@@ -257,7 +260,8 @@
if(((LPNMHDR)lParam)->code == TVN_SELCHANGED)
{
selected =
((LPNMTREEVIEW)lParam)->itemNew.lParam;
- PML_LoadPackage (tree, selected,
SetButton, SetText);
+ PML_LoadPackage (tree, selected,
SetButton);
+ SetText(PML_GetDescription (tree,
selected));
}
else if ((int)(((LPNMHDR)lParam)->code) ==
NM_RCLICK) // <= ahhh LISP
_____
Modified: trunk/rosapps/packmgr/lib/package.cpp
--- trunk/rosapps/packmgr/lib/package.cpp 2005-04-08 19:03:04 UTC
(rev 14552)
+++ trunk/rosapps/packmgr/lib/package.cpp 2005-04-08 19:09:20 UTC
(rev 14553)
@@ -84,16 +84,19 @@
// The user clicks on a package
-extern "C" int PML_LoadPackage (TREE* tree, int id, PML_SetButton
SetButton, PML_SetText SetText)
+extern "C" int PML_LoadPackage (TREE* tree, int id, PML_SetButton
SetButton)
{
PACKAGE* pack = &tree->packages[id];
tree->setButton = SetButton;
- SetButton(1, pack->action);
- SetButton(2, pack->inst); // && pack->action != 0
- SetButton(3, pack->src_inst);
- SetButton(4, pack->update);
- SetButton(5, pack->uninstall);
+ if(SetButton)
+ {
+ SetButton(1, pack->action);
+ SetButton(2, pack->inst); // && pack->action != 0
+ SetButton(3, pack->src_inst);
+ SetButton(4, pack->update);
+ SetButton(5, pack->uninstall);
+ }
// root notes (like network) return here
if(!pack->path)
@@ -105,12 +108,35 @@
pack->loaded = TRUE;
}
- if(pack->description)
- SetText(pack->description);
-
return ERR_OK;
}
+extern "C" int PML_FindItem (TREE* tree, const char* what)
+{
+ int i, j;
+ bool found;
+
+ // if we have children, same action for them
+ for (i=1; (UINT)i<tree->packages.size(); i++)
+ {
+ found = true;
+
+ for(j=0; (UINT)j<strlen(what); j++)
+ {
+ if(tolower(what[j]) !=
tolower(tree->packages[i].name[j]))
+ {
+ found = false;
+ break;
+ }
+ }
+
+ if(found)
+ return i;
+ }
+
+ return 0;
+}
+
// The user chooses a actions like Install
extern "C" int PML_SetAction (TREE* tree, int id, int action,
PML_SetIcon SetIcon)
{
@@ -134,7 +160,8 @@
// set the icon
if(!pack->icon)
- SetIcon(id, action);
+ if(SetIcon)
+ SetIcon(id, action);
// can't do src install yet
if(action == 2)
@@ -147,7 +174,8 @@
else if (action != 0)
{
// since we are setting a action we undo it again
- tree->setButton(1, 1);
+ if(tree->setButton)
+ tree->setButton(1, 1);
//tree->setButton(action+1, 0);
pack->action = action;
@@ -168,9 +196,10 @@
// undoing
else
- {+
+ {
// set other things back
- tree->setButton(1, 0);
+ if(tree->setButton)
+ tree->setButton(1, 0);
//tree->setButton(pack->action+1, 1);
pack->action = 0;
@@ -189,3 +218,11 @@
return ret;
}
+//
+extern "C" char* PML_GetDescription (TREE* tree, int id)
+{
+ PML_LoadPackage(tree, id, NULL);
+
+ return tree->packages[id].description;
+}
+
_____
Modified: trunk/rosapps/packmgr/lib/package.def
--- trunk/rosapps/packmgr/lib/package.def 2005-04-08 19:03:04 UTC
(rev 14552)
+++ trunk/rosapps/packmgr/lib/package.def 2005-04-08 19:09:20 UTC
(rev 14553)
@@ -5,7 +5,9 @@
PML_Abort
PML_TransError
PML_LoadTree
+ PML_FindItem
PML_LoadPackage
+ PML_GetDescription
PML_SetAction
PML_DoIt
PML_CloseTree
_____
Modified: trunk/rosapps/packmgr/lib/package.hpp
--- trunk/rosapps/packmgr/lib/package.hpp 2005-04-08 19:03:04 UTC
(rev 14552)
+++ trunk/rosapps/packmgr/lib/package.hpp 2005-04-08 19:09:20 UTC
(rev 14553)
@@ -71,7 +71,9 @@
WCHAR* PML_TransError (int code);
int PML_LoadTree (pTree*, char* url, PML_AddItem);
- int PML_LoadPackage (pTree, int id, PML_SetButton, PML_SetText);
+ int PML_FindItem (TREE* tree, const char* what);
+ int PML_LoadPackage (pTree, int id, PML_SetButton);
+ char* PML_GetDescription (TREE* tree, int id);
int PML_SetAction (pTree, int package, int action, PML_SetIcon);
int PML_DoIt (pTree, PML_SetStatus);
_____
Modified: trunk/rosapps/packmgr/lib/tree.cpp
--- trunk/rosapps/packmgr/lib/tree.cpp 2005-04-08 19:03:04 UTC (rev
14552)
+++ trunk/rosapps/packmgr/lib/tree.cpp 2005-04-08 19:09:20 UTC (rev
14553)
@@ -40,9 +40,8 @@
// expat callback for start of a "node" tag
void tree_start (void* usrdata, const char* tag, const char** arg)
{
- int i, icon;
+ int i, icon = 0;
static int id = 1;
- const char* name = "\0";
TREE* tree = (TREE*)usrdata;
@@ -58,12 +57,16 @@
tree->packages[id].icon = FALSE;
tree->packages[id].none = TRUE;
tree->packages[id].path = NULL;
+ tree->packages[id].name = "\0";
// read the arguments
for (i=0; arg[i]; i+=2)
{
if(!strcmp(arg[i], "name"))
- name = arg[i+1];
+ {
+ tree->packages[id].name = new char
[strlen(arg[i+1])+1];
+ strcpy(tree->packages[id].name, arg[i+1]);
+ }
if(!strcmp(arg[i], "icon"))
{
@@ -73,7 +76,7 @@
if(!strcmp(arg[i], "file"))
{
- tree->packages[id].path = new char
[strlen(arg[i+1])];
+ tree->packages[id].path = new char
[strlen(arg[i+1])+1];
strcpy(tree->packages[id].path, arg[i+1]);
if(strcmp(tag, "bin"))
@@ -84,14 +87,19 @@
}
}
- if(name[0]=='\0') return;
+ if(tree->packages[id].name[0] == '\0') return;
// add it
if(!parents.size())
- tree->addItem(id, name, 0, icon);
+ {
+ if(tree->addItem)
+ tree->addItem(id, tree->packages[id].name, 0,
icon);
+ }
+
+ // do some manipulation at the parent
else
{
- tree->addItem(id, name, parents.back(), icon);
+ tree->addItem(id, tree->packages[id].name,
parents.back(), icon);
// list as child in the parent node
tree->packages[parents.back()].children.push_back(id);
_____
Modified: trunk/rosapps/packmgr/tree/tree.xml
--- trunk/rosapps/packmgr/tree/tree.xml 2005-04-08 19:03:04 UTC (rev
14552)
+++ trunk/rosapps/packmgr/tree/tree.xml 2005-04-08 19:09:20 UTC (rev
14553)
@@ -1,69 +1,15 @@
<tree>
<node name="Internet and Network" icon="5">
- <node name="Browser" icon="5">
- <node name="MozillaControl" file="mozcontrol.xml"/>
- </node>
- <node name="Email" icon="5"/>
- <node name="Instant Messaging and IRC" icon="5">
- <node name="VoIP" icon="5"/>
- </node>
- <node name="Filesharing" icon="5"/>
- <node name="Remotecontrol" icon="5"/>
- <node name="Server" icon="5">
- <node name="File-Server" icon="5"/>
- <node name="HTTP" icon="5"/>
- <node name="IRC" icon="5"/>
- <node name="FTP" icon="5"/>
- </node>
- <node name="Network monitoring" icon="5"/>
- <node name="Security" icon="5"/>
- <node name="Streaming" icon="5"/>
- <node name="Other" icon="5"/>
+ <node name="Mozilla Control" file="mozcontrol.xml"/>
</node>
<node name="Office" icon="6">
- <node name="Writing" icon="6">
- <node name="PDF" icon="6"/>
- <node name="AbiWord" file="abiword.xml"/>
- </node>
- <node name="Dictionaries" icon="6"/>
+ <node name="AbiWord" file="abiword.xml"/>
</node>
- <node name="Graphics" icon="7">
- <node name="Vector" icon="7"/>
- <node name="Pixel" icon="7"/>
- <node name="3D" icon="7"/>
- </node>
- <node name="Multimedia" icon="8">
- <node name="Codecs" icon="8"/>
- <node name="Editors" icon="8"/>
- <node name="Players" icon="8"/>
- </node>
- <node name="Development" icon="9">
- <node name="IDE" icon="9"/>
- <node name="Compiler" icon="9"/>
- <node name="Version Control" icon="9"/>
- <node name="Web" icon="9"/>
- <node name="Other" icon="9"/>
- </node>
+ <node name="Graphics" icon="7"/>
+ <node name="Multimedia" icon="8"/>
+ <node name="Development" icon="9"/>
<node name="Games and Fun" icon="10"/>
- <node name="Tools" icon="11">
- <node name="Compression" icon="11"/>
- <node name="Backup" icon="11"/>
- <node name="Burning" icon="11">
- <node name="CD" icon="11"/>
- <node name="DVD" icon="11"/>
- </node>
- </node>
- <node name="Others" icon="12">
- <node name="Desktop Environments and Shellreplacements"
icon="12"/>
- <node name="Desktop" icon="12"/>
- <node name="Antivirus" icon="12"/>
- <node name="Emulators" icon="12">
- <node name="Computers" icon="12"/>
- <node name="Systems" icon="12"/>
- <node name="Games" icon="12"/>
- </node>
- <node name="Drivers" icon="12"/>
- </node>
- <node name="Installed Programms" icon="13"/>
-</tree>
-
+ <node name="Tools" icon="11"/>
+ <node name="Others" icon="12"/>
+ <node name="Installed Programms" icon="13"/>
+</tree>
\ No newline at end of file
_____
Added: trunk/rosapps/packmgr/tree/tree_withsubs.xml
--- trunk/rosapps/packmgr/tree/tree_withsubs.xml 2005-04-08
19:03:04 UTC (rev 14552)
+++ trunk/rosapps/packmgr/tree/tree_withsubs.xml 2005-04-08
19:09:20 UTC (rev 14553)
@@ -0,0 +1,69 @@
+<tree>
+ <node name="Internet and Network" icon="5">
+ <node name="Browser" icon="5">
+ <node name="MozillaControl" file="mozcontrol.xml"/>
+ </node>
+ <node name="Email" icon="5"/>
+ <node name="Instant Messaging and IRC" icon="5">
+ <node name="VoIP" icon="5"/>
+ </node>
+ <node name="Filesharing" icon="5"/>
+ <node name="Remotecontrol" icon="5"/>
+ <node name="Server" icon="5">
+ <node name="File-Server" icon="5"/>
+ <node name="HTTP" icon="5"/>
+ <node name="IRC" icon="5"/>
+ <node name="FTP" icon="5"/>
+ </node>
+ <node name="Network monitoring" icon="5"/>
+ <node name="Security" icon="5"/>
+ <node name="Streaming" icon="5"/>
+ <node name="Other" icon="5"/>
+ </node>
+ <node name="Office" icon="6">
+ <node name="Writing" icon="6">
+ <node name="PDF" icon="6"/>
+ <node name="AbiWord" file="abiword.xml"/>
+ </node>
+ <node name="Dictionaries" icon="6"/>
+ </node>
+ <node name="Graphics" icon="7">
+ <node name="Vector" icon="7"/>
+ <node name="Pixel" icon="7"/>
+ <node name="3D" icon="7"/>
+ </node>
+ <node name="Multimedia" icon="8">
+ <node name="Codecs" icon="8"/>
+ <node name="Editors" icon="8"/>
+ <node name="Players" icon="8"/>
+ </node>
+ <node name="Development" icon="9">
+ <node name="IDE" icon="9"/>
+ <node name="Compiler" icon="9"/>
+ <node name="Version Control" icon="9"/>
+ <node name="Web" icon="9"/>
+ <node name="Other" icon="9"/>
+ </node>
+ <node name="Games and Fun" icon="10"/>
+ <node name="Tools" icon="11">
+ <node name="Compression" icon="11"/>
+ <node name="Backup" icon="11"/>
+ <node name="Burning" icon="11">
+ <node name="CD" icon="11"/>
+ <node name="DVD" icon="11"/>
+ </node>
+ </node>
+ <node name="Others" icon="12">
+ <node name="Desktop Environments and Shellreplacements"
icon="12"/>
+ <node name="Desktop" icon="12"/>
+ <node name="Antivirus" icon="12"/>
+ <node name="Emulators" icon="12">
+ <node name="Computers" icon="12"/>
+ <node name="Systems" icon="12"/>
+ <node name="Games" icon="12"/>
+ </node>
+ <node name="Drivers" icon="12"/>
+ </node>
+ <node name="Installed Programms" icon="13"/>
+</tree>
+