19#define __STDBOOL_H__ 1
33#include <Application.h>
34#include <InterfaceKit.h>
38#include <private/interface/ColumnListView.h>
39#include <private/interface/ColumnTypes.h>
40#include <GroupLayoutBuilder.h>
41#include <NetworkCookieJar.h>
42#include <OutlineListView.h>
43#include <ScrollView.h>
44#include <StringView.h>
59 BStringItem*
_AddDomain(BString domain,
bool fake);
89 BDateField* dateField = (BDateField*)field;
90 if (dateField->UnixTime() == -1) {
108 SetField(
new BStringField(cookie.
name), 0);
109 SetField(
new BStringField(cookie.
path), 1);
110 time_t expiration = cookie.
expires;
111 SetField(
new BDateField(&expiration), 2);
112 SetField(
new BStringField(cookie.
value), 3);
120 SetField(
new BStringField(flags.String()), 4);
145 BWindow(frame,
"Cookie manager", B_TITLED_WINDOW,
146 B_NORMAL_WINDOW_FEEL,
147 B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS)
149 BGroupLayout*
root =
new BGroupLayout(B_HORIZONTAL, 0.0);
152 fDomains =
new BOutlineListView(
"domain list");
153 root->AddView(
new BScrollView(
"scroll",
fDomains, 0,
false,
true), 1);
155 fHeaderView =
new BStringView(
"label",
"The cookie jar is empty!");
156 fCookies =
new BColumnListView(
"cookie list", B_WILL_DRAW, B_FANCY_BORDER,
159 float em =
fCookies->StringWidth(
"M");
160 float flagsLength =
fCookies->StringWidth(
"Mhttps hostOnly" B_UTF8_ELLIPSIS);
162 fCookies->AddColumn(
new BStringColumn(
"Name",
163 20 * em, 10 * em, 50 * em, 0), 0);
164 fCookies->AddColumn(
new BStringColumn(
"Path",
165 10 * em, 10 * em, 50 * em, 0), 1);
167 fCookies->StringWidth(
"88/88/8888 88:88:88 AM")), 2);
168 fCookies->AddColumn(
new BStringColumn(
"Value",
169 20 * em, 10 * em, 50 * em, 0), 3);
170 fCookies->AddColumn(
new BStringColumn(
"Flags",
171 flagsLength, flagsLength, flagsLength, 0), 4);
173 root->AddItem(BGroupLayoutBuilder(B_VERTICAL, B_USE_DEFAULT_SPACING)
174 .SetInsets(5, 5, 5, 5)
175 .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
180 .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
181 .SetInsets(5, 5, 5, 5)
183 .Add(
new BButton(
"delete",
"Delete",
193 switch(message->what) {
196 int32 index = message->FindInt32(
"index");
197 BStringItem* item = (BStringItem*)
fDomains->ItemAt(index);
199 BString domain = item->Text();
213 BWindow::MessageReceived(message);
242 for (
int i =
fDomains->FullListCountItems() - 1; i >= 1; i--) {
255 for(std::vector<struct cookie_data*>::iterator it =
cookieJar.begin(); it !=
cookieJar.end(); ++it) {
260 while (i < fDomains->FullListCountItems())
264 item->SetOutlineLevel(item->OutlineLevel() - 1);
271 int firstNotEmpty = i;
273 while (i < fDomains->FullListCountItems())
276 if (item->
fEmpty ==
true) {
277 if (
fDomains->CountItemsUnder(item,
true) == 1) {
282 int index =
fDomains->FullListIndexOf(item) + 1;
283 for (
int j = 0; j <
count; j++) {
284 BListItem* child =
fDomains->FullListItemAt(index + j);
285 child->SetOutlineLevel(child->OutlineLevel() - 1);
297 item->SetEnabled(
false);
298 if (i == firstNotEmpty)
313 BStringItem*
parent = NULL;
314 int firstDot = domain.FindFirst(
'.');
316 BString parentDomain(domain);
317 parentDomain.Remove(0, firstDot + 1);
326 while ((existing =
fDomains->ItemUnderAt(
parent,
true, i++)) != NULL) {
328 if (stringItem->Text() == domain) {
330 stringItem->
fEmpty =
false;
336 BStringItem* domainItem =
new DomainItem(domain, fake);
337 domainItem->SetOutlineLevel(
parent->OutlineLevel() + 1);
338 BStringItem* sibling = NULL;
340 for (i = 0; i < siblingCount; i++) {
342 if (strcmp(sibling->Text(), domainItem->Text()) > 0) {
352 +
fDomains->CountItemsUnder(sibling,
false) + 1);
366 label.SetToFormat(
"Cookies for %s", domain.String());
374 for(std::vector<struct cookie_data*>::iterator it =
cookieJar.begin(); it !=
cookieJar.end(); ++it) {
375 if((*it)->domain == domain) {
static uint32_t count(const http_directive *list, lwc_string *key)
CookieDateColumn(const char *title, float width)
void DrawField(BField *field, BRect rect, BView *parent)
CookieRow(BColumnListView *list, struct cookie_data &cookie)
struct cookie_data fCookie
void _ShowCookiesForDomain(BString domain)
virtual void MessageReceived(BMessage *message)
CookieWindow(BRect frame)
BOutlineListView * fDomains
virtual bool QuitRequested()
BStringItem * _AddDomain(BString domain, bool fake)
BColumnListView * fCookies
BStringView * fHeaderView
DomainItem(BString text, bool empty)
Unified cookie database public interface.
void urldb_iterate_cookies(bool(*callback)(const struct cookie_data *cookie))
Iterate over all cookies in database.
void urldb_delete_cookie(const char *domain, const char *path, const char *name)
Delete a cookie.
Cookie Manager (interface).
static bool nsbeos_cookie_parser(const struct cookie_data *data)
void nsbeos_cookies_init(void)
Creates the Cookie Manager.
static std::vector< struct cookie_data * > cookieJar
static struct directory * root
Core mouse and pointer states.
Target independent plotting interface.
Interface to key press operations.
Interface to utility string handling.
const char * name
Cookie name.
const bool http_only
Only expose to HTTP(S) requests.
const char * domain
Domain.
const bool secure
Only send for HTTPS requests.
const char * value
Cookie value.
const time_t expires
Expiry timestamp, or 1 for session.
static struct search_node empty
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.