mirror of
https://github.com/reactos/reactos.git
synced 2024-12-25 16:50:57 +00:00
PackageManager: Depencies
svn path=/trunk/; revision=14576
This commit is contained in:
parent
56ec91131c
commit
e45867b698
8 changed files with 121 additions and 27 deletions
|
@ -174,6 +174,17 @@ int SetIcon (int id, int icon)
|
|||
return 1;
|
||||
}
|
||||
|
||||
// Set the Icons
|
||||
int Ask (const WCHAR* message)
|
||||
{
|
||||
int ans = MessageBox (0,message,0,MB_YESNO);
|
||||
|
||||
if(ans == IDYES)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// En- or Disable a Button inside of the toolbar and the Context Menu
|
||||
int SetButton (DWORD id, BOOL state)
|
||||
{
|
||||
|
@ -182,7 +193,12 @@ int SetButton (DWORD id, BOOL state)
|
|||
|
||||
ti.cbSize = sizeof (ti);
|
||||
ti.dwMask = TBIF_STATE;
|
||||
|
||||
/*
|
||||
if(state&&id==1)
|
||||
MessageBox(0,L"on",0,0);
|
||||
else if(!state&&id==1)
|
||||
MessageBox(0,L"off",0,0);
|
||||
*/
|
||||
if(state)
|
||||
ti.fsState = TBSTATE_ENABLED;
|
||||
else
|
||||
|
@ -294,7 +310,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
if(LOWORD(wParam) <= 5 && LOWORD(wParam) >= 1)
|
||||
{
|
||||
if(selected)
|
||||
if(PML_SetAction(tree, selected, LOWORD(wParam)-1, SetIcon) == ERR_OK)
|
||||
if(PML_SetAction(tree, selected, LOWORD(wParam)-1, SetIcon, Ask) == ERR_OK)
|
||||
break;
|
||||
|
||||
MessageBeep(MB_ICONHAND);
|
||||
|
@ -303,7 +319,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
// DoIt
|
||||
else if(LOWORD(wParam)==6)
|
||||
{
|
||||
if(PML_DoIt(tree, SetStatus) == ERR_OK)
|
||||
if(PML_DoIt(tree, SetStatus, Ask) == ERR_OK)
|
||||
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DOIT), hwnd, StatusProc);
|
||||
else
|
||||
MessageBeep(MB_ICONHAND);
|
||||
|
@ -325,7 +341,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
// prozess hotkeys
|
||||
case WM_HOTKEY:
|
||||
{
|
||||
if(PML_SetAction(tree, selected, wParam, SetIcon) != ERR_OK)
|
||||
if(PML_SetAction(tree, selected, wParam, SetIcon, Ask) != ERR_OK)
|
||||
MessageBeep(MB_ICONHAND);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -35,6 +35,7 @@ void Help (void);
|
|||
int AddItem (int id, const char* name, int parent, int icon);
|
||||
int SetText (const char* text);
|
||||
int SetStatus (int status1, int status2, WCHAR* text);
|
||||
int Ask (const WCHAR* message);
|
||||
|
||||
/* Toolbar Releated */
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <wine/urlmon.h>
|
||||
|
||||
// Server there all the files lie
|
||||
const char* tree_server = "http://svn.reactos.com/viewcvs/*checkout*/trunk/rosapps/packmgr/tree/";
|
||||
const char* tree_server = "http://maarten-online.de/xml/";
|
||||
|
||||
HRESULT WINAPI URLDownloadToFileA(
|
||||
LPUNKNOWN pCaller,
|
||||
|
|
|
@ -14,6 +14,10 @@ BEGIN
|
|||
ERR_SYNATX "Error while Script Execution.\nWrong Synatx."
|
||||
ERR_CALL "Error while Script Execution.\nCould not find function."
|
||||
ERR_PARAMETER "Error while Script Execution.\nWrong Parameter(s)."
|
||||
|
||||
ERR_DEP1 "To install this package you have to install the following package(s) as well:\n\n"
|
||||
ERR_DEP2 "\nDo you want this ?"
|
||||
ERR_READY "You choosen to install %d package(s). To install them you have to read and agree with each of thier licences.\n\n Do you want still want to ?"
|
||||
END
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
#define ERR_NOTODO 0x003 // without text yet
|
||||
#define ERR_PACK 0x004
|
||||
|
||||
#define ERR_DEP1 0x005
|
||||
#define ERR_DEP2 0x006
|
||||
#define ERR_READY 0x007
|
||||
|
||||
// Script
|
||||
#define ERR_SYNATX 0x011
|
||||
#define ERR_CALL 0x012
|
||||
|
|
|
@ -102,7 +102,7 @@ DWORD WINAPI DoitThread (void* lpParam)
|
|||
|
||||
// set all actions to none
|
||||
for(i=0; i<tree->packages.size(); i++)
|
||||
PML_SetAction (tree, i, 0, tree->setIcon);
|
||||
PML_SetAction (tree, i, 0, tree->setIcon, NULL);
|
||||
|
||||
tree->setStatus(1000, ret, NULL);
|
||||
|
||||
|
@ -110,7 +110,7 @@ DWORD WINAPI DoitThread (void* lpParam)
|
|||
}
|
||||
|
||||
// Do the actions the user wants us to do
|
||||
extern "C" int PML_DoIt (TREE* tree, PML_SetStatus SetStatus)
|
||||
extern "C" int PML_DoIt (TREE* tree, PML_SetStatus SetStatus, PML_Ask Ask)
|
||||
{
|
||||
DWORD dummy;
|
||||
tree->setStatus = SetStatus;
|
||||
|
@ -118,6 +118,14 @@ extern "C" int PML_DoIt (TREE* tree, PML_SetStatus SetStatus)
|
|||
if(!tree->todo.size())
|
||||
return ERR_NOTODO;
|
||||
|
||||
//ask
|
||||
WCHAR buffer [2000];
|
||||
wsprintf(buffer, PML_TransError(ERR_READY), tree->todo.size());
|
||||
|
||||
if(!Ask(buffer))
|
||||
return ERR_GENERIC;
|
||||
|
||||
|
||||
hThread = CreateThread(NULL, 0, DoitThread, tree, 0, &dummy);
|
||||
|
||||
if(!hThread)
|
||||
|
|
|
@ -58,6 +58,12 @@ void pack_start (void* usrdata, const char* tag, const char** arg)
|
|||
|
||||
else if(!strcmp(tag, "description"))
|
||||
pack->field = &pack->description;
|
||||
|
||||
else if (!strcmp(tag, "depent"))
|
||||
{
|
||||
pack->depencies.push_back((char*)NULL);
|
||||
pack->field = &pack->depencies.back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +88,6 @@ void pack_text (void* usrdata, const char* data, int len)
|
|||
(*pack->field)[len] = '\0';
|
||||
}
|
||||
|
||||
|
||||
// The user clicks on a package
|
||||
extern "C" int PML_LoadPackage (TREE* tree, int id, PML_SetButton SetButton)
|
||||
{
|
||||
|
@ -138,7 +143,7 @@ extern "C" int PML_FindItem (TREE* tree, const char* what)
|
|||
}
|
||||
|
||||
// The user chooses a actions like Install
|
||||
extern "C" int PML_SetAction (TREE* tree, int id, int action, PML_SetIcon SetIcon)
|
||||
extern "C" int PML_SetAction (TREE* tree, int id, int action, PML_SetIcon SetIcon, PML_Ask Ask)
|
||||
{
|
||||
UINT i;
|
||||
int ret = ERR_OK;
|
||||
|
@ -148,7 +153,7 @@ extern "C" int PML_SetAction (TREE* tree, int id, int action, PML_SetIcon SetIco
|
|||
|
||||
// if we have children, same action for them
|
||||
for (i=0; i<pack->children.size(); i++)
|
||||
ret = ret || PML_SetAction(tree, pack->children[i], action, SetIcon);
|
||||
ret = ret || PML_SetAction(tree, pack->children[i], action, SetIcon, Ask);
|
||||
|
||||
// is the action possible ?
|
||||
if(!pack->actions[action])
|
||||
|
@ -158,11 +163,66 @@ extern "C" int PML_SetAction (TREE* tree, int id, int action, PML_SetIcon SetIco
|
|||
if(pack->action == action)
|
||||
return ERR_OK;
|
||||
|
||||
//
|
||||
if(pack->depencies.size() && action)
|
||||
{
|
||||
UINT count = pack->depencies.size();
|
||||
WCHAR buffer[2000], buffer2[200];
|
||||
wcscpy(buffer, PML_TransError(ERR_DEP1));
|
||||
|
||||
for (i=0; i<pack->depencies.size(); i++)
|
||||
{
|
||||
int item = PML_FindItem(tree, pack->depencies[i]);
|
||||
|
||||
if(!item)
|
||||
return ERR_GENERIC;
|
||||
|
||||
if(action == tree->packages[item].action)// || tree->packages[item].installed
|
||||
{
|
||||
count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
MultiByteToWideChar (CP_ACP, 0, pack->depencies[i], strlen(pack->depencies[i])+1, buffer2, 200);
|
||||
wsprintf(buffer, L"%s - %s\n", buffer, buffer2);//
|
||||
}
|
||||
|
||||
wcscat(buffer, PML_TransError(ERR_DEP2));
|
||||
|
||||
if(count)
|
||||
if(!Ask(buffer))
|
||||
return ERR_GENERIC;
|
||||
|
||||
for (i=0; i<pack->depencies.size(); i++)
|
||||
{
|
||||
int item = PML_FindItem(tree, pack->depencies[i]);
|
||||
|
||||
tree->packages[item].neededBy.push_back(id);
|
||||
|
||||
PML_SetAction(tree, item, action, SetIcon, Ask);
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
pack->loaded = TRUE;
|
||||
|
||||
return PML_SetAction(tree, id, action, SetIcon, Ask);
|
||||
}
|
||||
|
||||
// set the icon
|
||||
if(!pack->icon)
|
||||
if(SetIcon)
|
||||
if(SetIcon && !pack->icon)
|
||||
SetIcon(id, action);
|
||||
|
||||
// set the button(s)
|
||||
if(tree->setButton && action != 2)
|
||||
{
|
||||
tree->setButton(1, action);
|
||||
//tree->setButton(pack->action+1, action);
|
||||
}
|
||||
|
||||
// can't do src install yet
|
||||
if(action == 2)
|
||||
{
|
||||
|
@ -177,19 +237,13 @@ extern "C" int PML_SetAction (TREE* tree, int id, int action, PML_SetIcon SetIco
|
|||
if(tree->setButton)
|
||||
tree->setButton(1, 1);
|
||||
//tree->setButton(action+1, 0);
|
||||
|
||||
pack->action = action;
|
||||
|
||||
// root notes (like network) return here
|
||||
if(!pack->path)
|
||||
return ret;
|
||||
|
||||
// load it if it's not loaded yet
|
||||
if(!pack->loaded)
|
||||
{
|
||||
PML_XmlDownload (pack->path, (void*)pack, pack_start, pack_end, pack_text);
|
||||
pack->loaded = TRUE;
|
||||
}
|
||||
|
||||
// save the name of the corresponding script in a vector
|
||||
tree->todo.push_back(pack->files[action-1]);
|
||||
}
|
||||
|
@ -197,10 +251,16 @@ extern "C" int PML_SetAction (TREE* tree, int id, int action, PML_SetIcon SetIco
|
|||
// undoing
|
||||
else
|
||||
{
|
||||
// set other things back
|
||||
if(tree->setButton)
|
||||
tree->setButton(1, 0);
|
||||
//tree->setButton(pack->action+1, 1);
|
||||
for(i=0; i<pack->neededBy.size(); i++)
|
||||
{
|
||||
if(tree->packages[pack->neededBy[i]].action)
|
||||
{
|
||||
SetIcon(id, pack->action);
|
||||
return ERR_GENERIC;
|
||||
}
|
||||
}
|
||||
|
||||
// set action back
|
||||
pack->action = 0;
|
||||
|
||||
// root notes (like network) return here
|
||||
|
@ -211,8 +271,6 @@ extern "C" int PML_SetAction (TREE* tree, int id, int action, PML_SetIcon SetIco
|
|||
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
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -18,6 +18,7 @@ typedef int (*PML_SetStatus) (int status1, int status2, WCHAR* text);
|
|||
typedef int (*PML_SetButton) (DWORD dwID, BOOL state);
|
||||
typedef int (*PML_SetIcon) (int id, int icon);
|
||||
typedef int (*PML_SetText) (const char* text);
|
||||
typedef int (*PML_Ask) (const WCHAR* text);
|
||||
|
||||
|
||||
/* Structs */
|
||||
|
@ -32,6 +33,8 @@ typedef struct
|
|||
char** field;
|
||||
char* name;
|
||||
char* description;
|
||||
vector<char*> depencies;
|
||||
vector<int> neededBy;
|
||||
|
||||
int action;
|
||||
char* files [4];
|
||||
|
@ -74,8 +77,8 @@ extern "C"
|
|||
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);
|
||||
int PML_SetAction (pTree, int package, int action, PML_SetIcon, PML_Ask);
|
||||
int PML_DoIt (pTree, PML_SetStatus, PML_Ask);
|
||||
|
||||
void PML_CloseTree (pTree);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue