| 81 |
fullPathName = *wikiDataDir + wxT("/") + *fileName; |
fullPathName = *wikiDataDir + wxT("/") + *fileName; |
| 82 |
fp = fopen((const char*)fullPathName.mb_str(), "r"); |
fp = fopen((const char*)fullPathName.mb_str(), "r"); |
| 83 |
if(fp == NULL) { |
if(fp == NULL) { |
| 84 |
MN_FATAL_ERROR(wxT("fopen faild")); |
return false; /* because of removed */ |
| 85 |
} |
} |
| 86 |
|
|
| 87 |
/* TYPE search */ |
/* TYPE search */ |
| 145 |
return list; |
return list; |
| 146 |
} |
} |
| 147 |
|
|
| 148 |
|
/* |
| 149 |
|
* add malon-type:xxx to search list |
| 150 |
|
*/ |
| 151 |
void mnModel::group() |
void mnModel::group() |
| 152 |
{ |
{ |
| 153 |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
| 201 |
iconv(codeSet, (ICONV_CONST char**)&inbufPtr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize); |
iconv(codeSet, (ICONV_CONST char**)&inbufPtr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize); |
| 202 |
|
|
| 203 |
typeToken = new wxString(outbuf, conv); |
typeToken = new wxString(outbuf, conv); |
| 204 |
addSearchStr(typeToken); |
if( addSearchStr(typeToken) ) { |
| 205 |
|
WikiList* wikiList = search(typeToken->mb_str()); |
| 206 |
|
addSearchList(typeToken, wikiList); |
| 207 |
|
} |
| 208 |
delete typeToken; |
delete typeToken; |
| 209 |
ptr = NULL; |
ptr = NULL; |
| 210 |
} |
} |
| 276 |
return false; |
return false; |
| 277 |
} |
} |
| 278 |
|
|
| 279 |
void mnModel::addSearchStr(wxString* searchStr) |
bool mnModel::addSearchStr(wxString* searchStr) |
| 280 |
{ |
{ |
| 281 |
wxString *string; |
wxString *string; |
| 282 |
|
|
| 284 |
string = new wxString(searchStr->c_str()); |
string = new wxString(searchStr->c_str()); |
| 285 |
searchStrList->Add(*string, 1); |
searchStrList->Add(*string, 1); |
| 286 |
//searchStrList->Insert(*string, 0); |
//searchStrList->Insert(*string, 0); |
| 287 |
|
return true; /* Add */ |
| 288 |
} |
} |
| 289 |
|
return false; /* does'nt add because of duplicating */ |
| 290 |
} |
} |
| 291 |
|
|
| 292 |
void mnModel::addSearchList(wxString* searchStr, WikiList* list) |
void mnModel::addSearchList(wxString* searchStr, WikiList* list) |
| 298 |
{ |
{ |
| 299 |
if(searchStrList->Index(searchStr.c_str()) != wxNOT_FOUND) { |
if(searchStrList->Index(searchStr.c_str()) != wxNOT_FOUND) { |
| 300 |
searchStrList->Remove(searchStr.c_str()); |
searchStrList->Remove(searchStr.c_str()); |
| 301 |
|
wikiHash[*searchStr] = NULL; |
| 302 |
} |
} |
| 303 |
} |
} |
| 304 |
|
|
| 311 |
itemStr.sprintf(wxT("%s"), newStr->c_str()); |
itemStr.sprintf(wxT("%s"), newStr->c_str()); |
| 312 |
} |
} |
| 313 |
} |
} |
| 314 |
|
|
| 315 |
|
void mnModel::clearSearchStrList() |
| 316 |
|
{ |
| 317 |
|
searchStrList->Clear(); |
| 318 |
|
} |
| 319 |
|
|
| 320 |
|
void mnModel::clearSearchResultList() |
| 321 |
|
{ |
| 322 |
|
wikiHash.clear(); |
| 323 |
|
} |
| 324 |
|
|
| 325 |
const wxString* mnModel::getWikiDataDir() |
const wxString* mnModel::getWikiDataDir() |
| 326 |
{ |
{ |
| 327 |
return wikiDataDir; |
return wikiDataDir; |
| 350 |
WikiList::Node* node; |
WikiList::Node* node; |
| 351 |
WikiData* data; |
WikiData* data; |
| 352 |
|
|
| 353 |
node = wikiList->GetFirst(); |
if(wikiList == NULL) { |
| 354 |
if(!node) { |
MN_FATAL_ERROR(wxT("wikiList is null")); |
| 355 |
MN_FATAL_ERROR(wxT("Search Result List is empty")); |
return; |
| 356 |
} |
} |
| 357 |
|
|
| 358 |
|
node = wikiList->GetFirst(); |
| 359 |
while(node) { |
while(node) { |
| 360 |
data = node->GetData(); |
data = node->GetData(); |
| 361 |
if(data == addData) return; |
if(data == addData) return; |
| 362 |
if( *(data->getSubject()) == *(addData->getSubject()) ) { |
if( *(data->getSubject()) == *(addData->getOldSubject()) ) { |
| 363 |
if(wikiList->DeleteObject(data)) { |
if(wikiList->DeleteObject(data)) { |
| 364 |
delete data; |
//delete data; /* may be wrong.. */ |
| 365 |
break; |
break; |
| 366 |
} |
} |
| 367 |
else { |
else { |
| 375 |
wikiList->Sort(compWikiData); |
wikiList->Sort(compWikiData); |
| 376 |
} |
} |
| 377 |
|
|
| 378 |
|
bool mnModel::delSearchResultList(wxString* searchStr, WikiData* delData) |
| 379 |
|
{ |
| 380 |
|
WikiList* wikiList = wikiHash[*searchStr]; |
| 381 |
|
WikiList::Node* node; |
| 382 |
|
WikiData* data; |
| 383 |
|
bool found = false; |
| 384 |
|
|
| 385 |
|
if(wikiList == NULL) { |
| 386 |
|
MN_FATAL_ERROR(wxT("wikiList is null")); |
| 387 |
|
return false; |
| 388 |
|
} |
| 389 |
|
|
| 390 |
|
node = wikiList->GetFirst(); |
| 391 |
|
while(node) { |
| 392 |
|
data = node->GetData(); |
| 393 |
|
if(data == delData) { |
| 394 |
|
if(!wikiList->DeleteObject(data)) { |
| 395 |
|
MN_FATAL_ERROR(wxT("Can't find delete data")); |
| 396 |
|
} |
| 397 |
|
found = true; |
| 398 |
|
break; |
| 399 |
|
} |
| 400 |
|
else if( *(data->getSubject()) == *(delData->getOldSubject()) ) { |
| 401 |
|
if(wikiList->DeleteObject(data)) { |
| 402 |
|
//delete data; /* may be wrong.. */ |
| 403 |
|
found = true; |
| 404 |
|
break; |
| 405 |
|
} |
| 406 |
|
else { |
| 407 |
|
MN_FATAL_ERROR(wxT("Can't find delete data")); |
| 408 |
|
} |
| 409 |
|
} |
| 410 |
|
node = node->GetNext(); |
| 411 |
|
} |
| 412 |
|
wikiList->Sort(compWikiData); |
| 413 |
|
return found; |
| 414 |
|
} |
| 415 |
|
|
| 416 |
/******* WikiData ************************/ |
/******* WikiData ************************/ |
| 417 |
WikiData::WikiData(wxString* dataDir, wxString* inFileName) |
WikiData::WikiData(wxString* dataDir, wxString* inFileName) |
| 418 |
{ |
{ |
| 434 |
|
|
| 435 |
text = NULL; |
text = NULL; |
| 436 |
memset(outbuf, 0, MAX_BUF_SIZE); |
memset(outbuf, 0, MAX_BUF_SIZE); |
| 437 |
fileName = new wxString(*inFileName); |
fileName = new wxString(inFileName->mb_str(), conv); |
| 438 |
dataDirName = dataDir; |
dataDirName = new wxString(dataDir->mb_str(), conv); |
| 439 |
decodeStr = decode(fileName->mb_str()); |
decodeStr = decode(fileName->mb_str()); |
| 440 |
inbufSize = strlen(decodeStr); |
inbufSize = strlen(decodeStr); |
| 441 |
outbufSize = sizeof(outbuf); |
outbufSize = sizeof(outbuf); |
| 442 |
iconv(codeSet, (ICONV_CONST char**)&decodeStr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize); |
iconv(codeSet, (ICONV_CONST char**)&decodeStr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize); |
| 443 |
subject = new wxString((const char*)outbuf, conv); |
subject = new wxString((const char*)outbuf, conv); |
| 444 |
|
oldSubject = new wxString((const char*)outbuf, conv); |
| 445 |
iconv_close(codeSet); |
iconv_close(codeSet); |
| 446 |
|
|
| 447 |
date = NULL; |
date = NULL; |
| 467 |
char buf[MAX_BUF_SIZE]; |
char buf[MAX_BUF_SIZE]; |
| 468 |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
| 469 |
|
|
| 470 |
dataDirName = dataDir; |
dataDirName = new wxString(dataDir->mb_str(), conv); |
| 471 |
|
|
| 472 |
time(&now); |
time(&now); |
| 473 |
memset(buf, 0, sizeof(buf)); |
memset(buf, 0, sizeof(buf)); |
| 474 |
strftime(buf, sizeof(buf), "%Y/%m/%d-%H%M%S",localtime(&now)); |
strftime(buf, sizeof(buf), "%Y/%m/%d-%H%M%S",localtime(&now)); |
| 475 |
subject = new wxString(buf, conv); |
subject = new wxString(buf, conv); |
| 476 |
|
oldSubject = new wxString(buf, conv); |
| 477 |
|
|
| 478 |
fileName = new wxString(encode(buf), conv); |
fileName = new wxString(encode(buf), conv); |
| 479 |
fileName->Append(wxT(EXT_TAG)); |
fileName->Append(wxT(EXT_TAG)); |
| 491 |
WikiData::~WikiData() |
WikiData::~WikiData() |
| 492 |
{ |
{ |
| 493 |
delete subject; |
delete subject; |
| 494 |
|
delete oldSubject; |
| 495 |
delete fileName; |
delete fileName; |
| 496 |
delete date; |
delete date; |
| 497 |
delete text; |
delete text; |
| 498 |
|
delete dataDirName; |
| 499 |
} |
} |
| 500 |
|
|
| 501 |
const wxString* WikiData::getFileName() |
const wxString* WikiData::getFileName() |
| 508 |
return subject; |
return subject; |
| 509 |
} |
} |
| 510 |
|
|
| 511 |
|
const wxString* WikiData::getOldSubject() |
| 512 |
|
{ |
| 513 |
|
return oldSubject; |
| 514 |
|
} |
| 515 |
|
|
| 516 |
void WikiData::modSubject(wxString* newSubject) |
void WikiData::modSubject(wxString* newSubject) |
| 517 |
{ |
{ |
| 518 |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
| 519 |
wxString* oldFileName = fileName; |
wxString* oldFileName = fileName; |
|
wxString* oldSubject = subject; |
|
| 520 |
char oldFullPath[MAX_BUF_SIZE]; |
char oldFullPath[MAX_BUF_SIZE]; |
| 521 |
char newFullPath[MAX_BUF_SIZE]; |
char newFullPath[MAX_BUF_SIZE]; |
| 522 |
iconv_t codeSet; |
iconv_t codeSet; |
| 528 |
int outbufSize = sizeof(outbuf); |
int outbufSize = sizeof(outbuf); |
| 529 |
FILE* fp; |
FILE* fp; |
| 530 |
|
|
| 531 |
|
oldSubject = subject; |
| 532 |
|
|
| 533 |
memset(outbuf, 0, outbufSize); |
memset(outbuf, 0, outbufSize); |
| 534 |
memset(inbuf, 0, sizeof(inbuf)); |
memset(inbuf, 0, sizeof(inbuf)); |
| 535 |
strcpy(inbuf, (const char*)newSubject->mb_str()); |
strcpy(inbuf, (const char*)newSubject->mb_str()); |
| 558 |
fclose(fp); |
fclose(fp); |
| 559 |
} |
} |
| 560 |
|
|
|
delete oldSubject; |
|
| 561 |
delete oldFileName; |
delete oldFileName; |
| 562 |
} |
} |
| 563 |
|
|
| 623 |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
| 624 |
delete text; |
delete text; |
| 625 |
//text = new wxString(intext->c_str()); |
//text = new wxString(intext->c_str()); |
| 626 |
text = new wxString(*intext); |
//text = new wxString(*intext); |
| 627 |
//text = new wxString(intext->mb_str(), conv); |
text = new wxString(intext->mb_str(), conv); |
| 628 |
} |
} |
| 629 |
|
|
| 630 |
void WikiData::removeDataFile() |
void WikiData::removeDataFile() |