1/*
2 * Copyright 2010, Haiku, Inc.
3 * Distributed under the terms of the MIT license.
4 *
5 * Author:
6 *		Adrien Destugues <pulkomandy@pulkomandy.ath.cx>
7 */
8
9
10#include "ApplicationWindow.h"
11
12#include <Application.h>
13#include <Catalog.h>
14#include <Entry.h>
15#include <TextView.h>
16#include <Locale.h>
17
18
19#undef B_TRANSLATION_CONTEXT
20#define B_TRANSLATION_CONTEXT "main"
21
22
23class PackageManager : public BApplication {
24	public:
25		PackageManager();
26		~PackageManager();
27
28		void RefsReceived(BMessage *msg);
29		void ArgvReceived(int32 argc, char **argv);
30		void ReadyToRun();
31
32		void MessageReceived(BMessage *msg);
33
34	private:
35		ApplicationWindow* fMainWindow;
36};
37
38
39PackageManager::PackageManager()
40	:	BApplication("application/x-vnd.Haiku-PackageManager")
41{
42}
43
44
45PackageManager::~PackageManager()
46{
47}
48
49
50void
51PackageManager::ReadyToRun()
52{
53	// Open the main window
54	BRect frame(20, 40, 600, 400);
55	fMainWindow = new ApplicationWindow(frame, true);
56
57	// Add some test content to the window
58	fMainWindow->AddCategory("Test category", "development",
59		"Thisis a short description of the category");
60
61	BMessage entryInfo;
62	// This message is a convenient way of storing various infos about an app.
63	// What's inside :
64	// icon as an archived BBitmap
65	entryInfo.AddString("appname", "Test Application");
66	entryInfo.AddString("appdesc", "Some text telling what it does");
67	entryInfo.AddFloat("appver", 1.302);
68		// as a float so it can be compared to decide if there is an update
69	entryInfo.AddInt32("appsize", 123456); // this is in bytes
70
71	fMainWindow->AddApplication(&entryInfo);
72
73	fMainWindow->Show();
74}
75
76
77void
78PackageManager::RefsReceived(BMessage *msg)
79{
80	uint32 type;
81	int32 i, count;
82	status_t ret = msg->GetInfo("refs", &type, &count);
83	if (ret != B_OK || type != B_REF_TYPE)
84		return;
85
86	entry_ref ref;
87	for (i = 0; i < count; i++) {
88		if (msg->FindRef("refs", i, &ref) == B_OK) {
89			// TODO: handle bundle-files for installation
90		}
91	}
92}
93
94
95void
96PackageManager::ArgvReceived(int32 argc, char **argv)
97{
98	// TODO: handle command-line driven actions
99}
100
101
102void
103PackageManager::MessageReceived(BMessage *msg)
104{
105	switch (msg->what) {
106		default:
107			BApplication::MessageReceived(msg);
108	}
109}
110
111
112int
113main(void)
114{
115	PackageManager app;
116	app.Run();
117
118	return 0;
119}
120
121