Now creates the People indices on all mounted volumes on startup (like R5's People).
Some more cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13138 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,14 +1,15 @@
|
|||||||
//--------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// PeopleApp.cpp
|
|
||||||
//
|
|
||||||
// Written by: Robert Polic
|
|
||||||
//
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
/*
|
/*
|
||||||
Copyright 1999, Be Incorporated. All Rights Reserved.
|
* Copyright 2005, Haiku, Inc.
|
||||||
This file may be used under the terms of the Be Sample Code License.
|
* Distributed under the terms of the MIT license.
|
||||||
*/
|
*
|
||||||
|
* Authors:
|
||||||
|
* Robert Polic
|
||||||
|
* Axel Dörfler, [email protected]
|
||||||
|
*
|
||||||
|
* Copyright 1999, Be Incorporated. All Rights Reserved.
|
||||||
|
* This file may be used under the terms of the Be Sample Code License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
@@ -17,15 +18,15 @@
|
|||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <fs_index.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
|
#include <fs_index.h>
|
||||||
|
|
||||||
#include "PeopleApp.h"
|
#include "PeopleApp.h"
|
||||||
#include "PeopleWindow.h"
|
#include "PeopleWindow.h"
|
||||||
#include "PersonIcons.h"
|
#include "PersonIcons.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
struct people_field gFields[] = {
|
struct people_field gFields[] = {
|
||||||
{ "META:name", 120, "Contact Name" },
|
{ "META:name", 120, "Contact Name" },
|
||||||
@@ -47,23 +48,17 @@ struct people_field gFields[] = {
|
|||||||
|
|
||||||
|
|
||||||
TPeopleApp::TPeopleApp(void)
|
TPeopleApp::TPeopleApp(void)
|
||||||
: BApplication(APP_SIG)
|
: BApplication(APP_SIG),
|
||||||
|
fHaveWindow(false)
|
||||||
{
|
{
|
||||||
const char *str;
|
|
||||||
int32 index = 0;
|
|
||||||
BDirectory dir;
|
|
||||||
BEntry entry;
|
|
||||||
BMessage msg;
|
|
||||||
BMessage info;
|
|
||||||
BPath path;
|
|
||||||
|
|
||||||
fHaveWindow = false;
|
|
||||||
|
|
||||||
fPosition.Set(6, TITLE_BAR_HEIGHT, 6 + WIND_WIDTH, TITLE_BAR_HEIGHT + WIND_HEIGHT);
|
fPosition.Set(6, TITLE_BAR_HEIGHT, 6 + WIND_WIDTH, TITLE_BAR_HEIGHT + WIND_HEIGHT);
|
||||||
BPoint pos = fPosition.LeftTop();
|
BPoint pos = fPosition.LeftTop();
|
||||||
|
|
||||||
|
BPath path;
|
||||||
find_directory(B_USER_SETTINGS_DIRECTORY, &path, true);
|
find_directory(B_USER_SETTINGS_DIRECTORY, &path, true);
|
||||||
dir.SetTo(path.Path());
|
|
||||||
|
BDirectory dir(path.Path());
|
||||||
|
BEntry entry;
|
||||||
if (dir.FindEntry("People_data", &entry) == B_NO_ERROR) {
|
if (dir.FindEntry("People_data", &entry) == B_NO_ERROR) {
|
||||||
fPrefs = new BFile(&entry, B_READ_WRITE);
|
fPrefs = new BFile(&entry, B_READ_WRITE);
|
||||||
if (fPrefs->InitCheck() == B_NO_ERROR) {
|
if (fPrefs->InitCheck() == B_NO_ERROR) {
|
||||||
@@ -79,15 +74,14 @@ TPeopleApp::TPeopleApp(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// create indices on the boot volume
|
// create indices on all volumes
|
||||||
// ToDo: on other volumes as well?
|
|
||||||
|
|
||||||
BVolumeRoster roster;
|
BVolumeRoster volumeRoster;
|
||||||
BVolume volume;
|
BVolume volume;
|
||||||
roster.GetBootVolume(&volume);
|
while (volumeRoster.GetNextVolume(&volume) == B_OK) {
|
||||||
|
for (int32 i = 0; gFields[i].attribute; i++) {
|
||||||
for (int32 i = 0; gFields[i].attribute; i++) {
|
fs_create_index(volume.Device(), gFields[i].attribute, B_STRING_TYPE, 0);
|
||||||
fs_create_index(volume.Device(), gFields[i].attribute, B_STRING_TYPE, 0);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// install person mime type
|
// install person mime type
|
||||||
@@ -97,9 +91,12 @@ TPeopleApp::TPeopleApp(void)
|
|||||||
mime.SetType(B_PERSON_MIMETYPE);
|
mime.SetType(B_PERSON_MIMETYPE);
|
||||||
|
|
||||||
if (mime.IsInstalled()) {
|
if (mime.IsInstalled()) {
|
||||||
|
BMessage info;
|
||||||
if (mime.GetAttrInfo(&info) == B_NO_ERROR) {
|
if (mime.GetAttrInfo(&info) == B_NO_ERROR) {
|
||||||
while (info.FindString("attr:name", index++, &str) == B_NO_ERROR) {
|
const char *string;
|
||||||
if (!strcmp(str, gFields[0].attribute)) {
|
int32 index = 0;
|
||||||
|
while (info.FindString("attr:name", index++, &string) == B_OK) {
|
||||||
|
if (!strcmp(string, gFields[0].attribute)) {
|
||||||
valid = true;
|
valid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -123,18 +120,19 @@ TPeopleApp::TPeopleApp(void)
|
|||||||
|
|
||||||
// add relevant person fields to meta-mime type
|
// add relevant person fields to meta-mime type
|
||||||
|
|
||||||
|
BMessage fields;
|
||||||
for (int32 i = 0; gFields[i].attribute; i++) {
|
for (int32 i = 0; gFields[i].attribute; i++) {
|
||||||
msg.AddString("attr:public_name", gFields[i].name);
|
fields.AddString("attr:public_name", gFields[i].name);
|
||||||
msg.AddString("attr:name", gFields[i].attribute);
|
fields.AddString("attr:name", gFields[i].attribute);
|
||||||
msg.AddInt32("attr:type", B_STRING_TYPE);
|
fields.AddInt32("attr:type", B_STRING_TYPE);
|
||||||
msg.AddBool("attr:viewable", true);
|
fields.AddBool("attr:viewable", true);
|
||||||
msg.AddBool("attr:editable", true);
|
fields.AddBool("attr:editable", true);
|
||||||
msg.AddInt32("attr:width", gFields[i].width);
|
fields.AddInt32("attr:width", gFields[i].width);
|
||||||
msg.AddInt32("attr:alignment", B_ALIGN_LEFT);
|
fields.AddInt32("attr:alignment", B_ALIGN_LEFT);
|
||||||
msg.AddBool("attr:extra", false);
|
fields.AddBool("attr:extra", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
mime.SetAttrInfo(&msg);
|
mime.SetAttrInfo(&fields);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user