00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #define _GNU_SOURCE
00036
00037 #include <config.h>
00038
00039 #include <errno.h>
00040 #include <stdio.h>
00041 #include <string.h>
00042 #include <sys/stat.h>
00043 #include <sys/types.h>
00044 #include <unistd.h>
00045
00046 #include <gdk/gdk.h>
00047 #include <gtk/gtk.h>
00048
00049 #include <liberregxml/erregapi.h>
00050 #include <libergtk/ergtk.h>
00051 #include <liberipc/eripctoolbar.h>
00052 #include <libermanifest/ermanifest.h>
00053
00054 #include "contentListerLog.h"
00055 #include "erConnect.h"
00056 #include "system.h"
00057 #include "gtkPincodeScreen.h"
00058 #include "control.h"
00059 #include "cursor.h"
00060 #include "displayUpdate.h"
00061 #include "erMdsContent.h"
00062 #include "gtkDistListWnd.h"
00063 #include "control_share.h"
00064 #include "erbusy.h"
00065 #include "sign.h"
00066 #include "system.h"
00067 #include "toolbar.h"
00068 #include "pagebar.h"
00069 #include "languages.h"
00070
00071
00072 typedef enum
00073 {
00074 dl_approve = 0,
00075 dl_reject,
00076 dl_undefined
00077 } dist_list_reason_e;
00078
00079
00080 static struct
00081 {
00082 int index;
00083 gboolean do_move;
00084 gboolean do_sign;
00085 ContentLister* theContentLister;
00086 } g_item_to_be_shared;
00087
00088 static const mdsSelectionList_t* g_selectionList = NULL;
00089 static erGtkSelectionGroup** g_selection_groups;
00090
00091
00092
00093 static gboolean ctrl_send_to_outbox(const gchar* szSourcename, const gboolean bDeleteOriginal);
00094 static gchar* ctrl_sign_container(const char* szSourcename);
00095 static void ctrl_sign_pincode_ok(void);
00096 static void ctrl_sign_pincode_quit(void);
00097 static gboolean ctrl_show_sel_list_wnd(int itemIndex, ContentLister* theContentLister);
00098
00099
00100
00101
00102
00103
00104 static gboolean ctrl_send_to_outbox(const gchar* szSourcename, const gboolean bDeleteOriginal)
00105 {
00106 gboolean bRet = FALSE;
00107 const gchar* device = NULL;
00108 const gchar* szFilename = NULL;
00109 gchar* szTargetname = NULL;
00110 int argc;
00111 char* argv[10];
00112 struct stat status;
00113 int rc;
00114 int i;
00115 char* cp;
00116
00117 CL_CONTROLPRINTF("entry: item [%s] delete [%d]", szSourcename, bDeleteOriginal);
00118
00119
00120 device = ctrl_is_trusted_path(szSourcename);
00121 if (device == NULL)
00122 {
00123
00124 CL_ERRORPRINTF("Item not on a trusted filesystem [%s]", szSourcename);
00125 }
00126 else
00127 {
00128
00129 szFilename = strrchr(szSourcename, '/');
00130 g_return_val_if_fail((szFilename != NULL), FALSE);
00131 szFilename++;
00132
00133
00134 szTargetname = alloca( strlen(device) + 1 + strlen(OUTBOX_NAME) + 1 + strlen(szFilename) + 3 + 1 );
00135 g_assert(szTargetname != NULL);
00136 sprintf(szTargetname, "%s/" OUTBOX_NAME, device);
00137 (void)mkdir(szTargetname, 0755);
00138
00139
00140 strcat(szTargetname, "/");
00141 strcat(szTargetname, szFilename);
00142
00143 cp = szTargetname + strlen(szTargetname);
00144 for (i = 1 ; lstat(szTargetname, &status) == 0 && i <= 99 ; i++)
00145 {
00146 sprintf(cp, "_%02d", i);
00147 }
00148 if (i > 99)
00149 {
00150 CL_ERRORPRINTF("Target already exists [%s]", szTargetname);
00151 }
00152 else
00153 {
00154
00155 if (bDeleteOriginal)
00156 {
00157
00158 rc = rename(szSourcename, szTargetname);
00159 if (rc == 0)
00160 {
00161 sync();
00162 bRet = TRUE;
00163 }
00164 else
00165 {
00166 CL_ERRORPRINTF( "Cannot rename [%s] to [%s] - error [%d] [%s]",
00167 szSourcename, szTargetname, errno, strerror(errno) );
00168 }
00169 }
00170 else
00171 {
00172
00173
00174 argc = 0;
00175 argv[argc++] = "cp";
00176 argv[argc++] = "-r";
00177
00178 cp = alloca( strlen(szSourcename) + 1 );
00179 g_assert(cp != NULL);
00180 strcpy( cp, szSourcename);
00181 argv[argc++] = cp;
00182
00183 cp = alloca( strlen(szTargetname) + 1 );
00184 g_assert(cp != NULL);
00185 strcpy( cp, szTargetname);
00186 argv[argc++] = cp;
00187
00188 argv[argc] = NULL;
00189 g_assert( argc < (sizeof(argv)/sizeof(argv[0])) );
00190 rc = fork_exec(argc, argv);
00191 if (rc == 0)
00192 {
00193 sync();
00194 bRet = TRUE;
00195 }
00196 else
00197 {
00198 CL_ERRORPRINTF( "Cannot copy [%s] to [%s] - error [%d] [%s]",
00199 szSourcename, szTargetname, rc, strerror(rc) );
00200 }
00201 }
00202 }
00203 }
00204
00205
00206 return bRet;
00207 }
00208
00209
00210
00211 void ctrl_listItem_share(const int* index_tbl, ContentLister* theContentLister)
00212 {
00213 gboolean ok;
00214
00215 CL_CONTROLPRINTF("entry: index [%d]", *index_tbl);
00216 g_assert(theContentLister != NULL);
00217
00218
00219 const int index = *index_tbl;
00220 g_assert(index >= 0 && index < theContentLister->itemCount);
00221
00222
00223 clDisplayItem_t* theItem = theContentLister->items + index;
00224
00225 erbusy_blink();
00226
00227
00228 mdsSetIndex(theContentLister->currentContentType, index + ((theContentLister->currentPage - 1) * MAX_ITEMS_ON_ONE_PAGE));
00229
00230
00231 g_item_to_be_shared.index = index;
00232 g_item_to_be_shared.do_move = FALSE;
00233 g_item_to_be_shared.do_sign = FALSE;
00234 g_item_to_be_shared.theContentLister = theContentLister;
00235
00236
00237 if (theItem->fit == mdsFitFile)
00238 {
00239 ctrl_before_file_clicked(theItem);
00240 }
00241
00242
00243 if (theItem->fit == mdsFitContainer)
00244 {
00245 display_update_increase_level(MAIN_WINDOW_EXPOSE_LEVEL);
00246 ok = ctrl_show_sel_list_wnd(index, theContentLister);
00247 if (ok)
00248 {
00249 display_update_request_screen_refresh(MAIN_WINDOW_EXPOSE_LEVEL);
00250 }
00251 else
00252 {
00253 CL_WARNPRINTF("-- cannot show dist_list_wnd");
00254 toolbar_setIconState(iconID_share, iconState_normal);
00255 toolbar_synchronise();
00256 }
00257 }
00258 else
00259 {
00260 CL_WARNPRINTF("-- not allowed to share item [%s] fit [%d] ", theItem->szFilename, theItem->fit);
00261 toolbar_setIconState(iconID_share, iconState_normal);
00262 toolbar_synchronise();
00263 }
00264 }
00265
00266 void ctrl_doc_share_now(ContentLister* theContentLister)
00267 {
00268 CL_CONTROLPRINTF("entry");
00269
00270 gchar* szContainerName;
00271 gchar* cp;
00272
00273 if ( g_selectionList != NULL
00274 && g_item_to_be_shared.index >= 0 )
00275 {
00276 clDisplayItem_t* theItem = theContentLister->items + g_item_to_be_shared.index;
00277
00278 erbusy_blink();
00279
00280
00281 ctrl_hide_sel_list_wnd(theContentLister, TRUE);
00282
00283
00284 if (g_item_to_be_shared.do_sign)
00285 {
00286
00287 ctrl_show_pincode_screen(signDocument_t, ctrl_sign_pincode_ok, ctrl_sign_pincode_quit);
00288 }
00289 else
00290 {
00291
00292 szContainerName = alloca( strlen(theItem->szManifest) + 1 );
00293 g_assert(szContainerName != NULL);
00294 strcpy(szContainerName, theItem->szManifest);
00295 cp = strrchr(szContainerName, '/');
00296 g_return_if_fail(cp != NULL);
00297 *cp = '\0';
00298
00299
00300 ctrl_send_to_outbox(szContainerName, g_item_to_be_shared.do_move);
00301 if (g_item_to_be_shared.do_move)
00302 {
00303 ctrl_rescan_current();
00304 }
00305
00306
00307 g_item_to_be_shared.index = -1;
00308 }
00309 }
00310 }
00311
00312
00313
00314 static gchar* ctrl_sign_container(const char* szSourceContainer)
00315 {
00316 int n;
00317 int rc;
00318 erManifest manifest;
00319 struct stat status;
00320 char* cp;
00321 const char* ccp;
00322 int argc;
00323 char* argv[10];
00324 time_t t_time;
00325 struct tm* tm_time;
00326
00327 gchar* szDateTime = NULL;
00328 gchar* szSourceName = NULL;
00329 gchar* szSourceManifest = NULL;
00330 gchar* szSourceManifestOld = NULL;
00331 gchar* szTargetContainer = NULL;
00332 gchar* szTargetTarfile = NULL;
00333 gchar* szTargetSignature = NULL;
00334 regUserProfile_t* theUserProfile = NULL;
00335
00336
00337 CL_CONTROLPRINTF("entry: source [%s]", szSourceContainer);
00338
00339
00340 n = 19 + 1;
00341 szDateTime = alloca(n);
00342 g_assert(szDateTime != NULL);
00343 t_time = time(NULL);
00344 tm_time = localtime( &t_time );
00345 snprintf( szDateTime,
00346 n,
00347 "%04d-%02d-%02dT%02d:%02d:%02d",
00348 tm_time->tm_year + 1900,
00349 tm_time->tm_mon + 1,
00350 tm_time->tm_mday,
00351 tm_time->tm_hour,
00352 tm_time->tm_min,
00353 tm_time->tm_sec );
00354
00355
00356
00357 szSourceName = strrchr(szSourceContainer, '/');
00358 if (szSourceName == NULL)
00359 {
00360 CL_ERRORPRINTF("Illegal container name [%s]", szSourceContainer);
00361 return NULL;
00362 }
00363 szSourceName++;
00364
00365 n = strlen(szSourceContainer) + 1 + 8 + strlen(szDateTime) + 1;
00366 szTargetContainer = alloca(n);
00367 g_assert(szTargetContainer != NULL);
00368 strcpy(szTargetContainer, szSourceContainer);
00369 cp= strrchr(szTargetContainer, '/');
00370 g_assert(cp != NULL);
00371 strcpy(cp, "/Signed_");
00372 strcat(cp, szDateTime);
00373 while ( (cp = strchr(szTargetContainer, ':')) != NULL)
00374 {
00375 *cp = '-';
00376 }
00377
00378 n = strlen(szTargetContainer) + 1 + strlen(szSourceName) + strlen(TARFILE_EXTENSION) + 1;
00379 szTargetTarfile = alloca(n);
00380 g_assert(szTargetTarfile != NULL);
00381 snprintf(szTargetTarfile, n, "%s/%s%s", szTargetContainer, szSourceName, TARFILE_EXTENSION);
00382
00383 n = strlen(szTargetContainer) + 1 + strlen(szSourceName) + strlen(SIGNATURE_EXTENSION) + 1;
00384 szTargetSignature = alloca(n);
00385 g_assert(szTargetSignature != NULL);
00386 snprintf(szTargetSignature, n, "%s/%s%s", szTargetContainer, szSourceName, SIGNATURE_EXTENSION);
00387
00388
00389 if (lstat(szTargetContainer, &status) == 0)
00390 {
00391 CL_WARNPRINTF("-- container already present [%s]", szTargetContainer);
00392
00393 argc = 0;
00394 argv[argc++] = "rm";
00395 argv[argc++] = "-rf";
00396
00397 cp = alloca( strlen(szTargetContainer) + 1 );
00398 g_assert(cp != NULL);
00399 strcpy(cp, szTargetContainer);
00400 argv[argc++] = cp;
00401
00402 argv[argc] = NULL;
00403 g_assert( argc < (sizeof(argv)/sizeof(argv[0])) );
00404 rc = fork_exec(argc, argv);
00405 if (rc != 0)
00406 {
00407 CL_ERRORPRINTF( "Cannot remove container [%s] - error [%d] [%s]",
00408 szTargetContainer, rc, strerror(rc) );
00409 return NULL;
00410 }
00411 }
00412
00413
00414
00415 if (RET_OK != ermXmlOpenManifest(szSourceContainer, &manifest))
00416 {
00417 CL_ERRORPRINTF("Cannot open manifest file in [%s]", szSourceContainer);
00418 return NULL;
00419 }
00420
00421 ccp = ermXmlGetFileName(&manifest);
00422 szSourceManifest = alloca( strlen(ccp) + 1 );
00423 g_assert(szSourceManifest != NULL);
00424 strcpy(szSourceManifest, ccp);
00425
00426 n = strlen(szSourceManifest) + 4 + 1;
00427 szSourceManifestOld = alloca(n);
00428 g_assert(szSourceManifestOld != NULL);
00429 snprintf(szSourceManifestOld, n, "%s.old", szSourceManifest);
00430 rc = ermXmlSaveAs(&manifest, szSourceManifestOld);
00431 if (rc != RET_OK)
00432 {
00433 CL_ERRORPRINTF("Cannot save manifest file [%s]", szSourceManifestOld);
00434 return NULL;
00435 }
00436
00437 if (RET_OK == ermXmlExist(&manifest, XMLNODE_DOCUMENT_SIGNING))
00438 {
00439 CL_WARNPRINTF("-- document-signing info already present in [%s]", szSourceManifest);
00440 ermXmlRemoveNode(&manifest, XMLNODE_DOCUMENT_SIGNING);
00441 }
00442
00443 ermXmlNewString(&manifest, XMLNODE_DOCUMENT_SIGNING_PARENT, XMLNODE_DOCUMENT_SIGNING_NODENAME, "");
00444 ermXmlNewString(&manifest, XMLNODE_DOCUMENT_SIGNING, "signed-by", "");
00445 ermXmlNewString(&manifest, XMLNODE_DOCUMENT_SIGNING, "iliad-mac-address", "");
00446 ermXmlNewString(&manifest, XMLNODE_DOCUMENT_SIGNING, "date", "");
00447
00448 theUserProfile = erRegGetUserProfile();
00449 if (theUserProfile)
00450 {
00451 if (theUserProfile->email)
00452 {
00453 CL_CONTROLPRINTF("email [%s]", theUserProfile->email);
00454 ermXmlSetString(&manifest, XMLNODE_DOCUMENT_SIGNING "/signed-by", theUserProfile->email);
00455 }
00456 erRegFreeUserProfile(theUserProfile);
00457 theUserProfile = NULL;
00458 }
00459
00460 CL_CONTROLPRINTF("MAC address [%s]", get_sysset_macAddress());
00461 ermXmlSetString(&manifest, XMLNODE_DOCUMENT_SIGNING "/iliad-mac-address", get_sysset_macAddress());
00462
00463 CL_CONTROLPRINTF("date [%s]", szDateTime);
00464 ermXmlSetString(&manifest, XMLNODE_DOCUMENT_SIGNING "/date", szDateTime);
00465
00466 rc = ermXmlSaveAs(&manifest, szSourceManifest);
00467 if (rc != RET_OK)
00468 {
00469 CL_ERRORPRINTF("Cannot save manifest file [%s]", szSourceManifest);
00470 (void)rename(szSourceManifestOld, szSourceManifest);
00471 return NULL;
00472 }
00473 ermXmlClose(&manifest);
00474
00475
00476 rc = mkdir(szTargetContainer, 0755);
00477 if (rc != 0)
00478 {
00479 CL_ERRORPRINTF("Cannot not create folder [%s] - error [%d] [%s]", szTargetContainer, errno, strerror(errno));
00480 (void)rename(szSourceManifestOld, szSourceManifest);
00481 return NULL;
00482 }
00483
00484
00485 rc = chdir(szSourceContainer);
00486 if (rc != 0)
00487 {
00488 CL_ERRORPRINTF("Cannot chdir to [%s] - error [%d] [%s]", szSourceContainer, errno, strerror(errno));
00489 (void)rename(szSourceManifestOld, szSourceManifest);
00490 return NULL;
00491 }
00492 rc = chdir("..");
00493 if (rc != 0)
00494 {
00495 CL_ERRORPRINTF("Cannot chdir to [%s/..] - error [%d] [%s]", szSourceContainer, errno, strerror(errno));
00496 (void)rename(szSourceManifestOld, szSourceManifest);
00497 return NULL;
00498 }
00499
00500 argc = 0;
00501 argv[argc++] = "tar";
00502 argv[argc++] = "-czf";
00503
00504 cp = alloca( strlen(szTargetTarfile) + 1 );
00505 g_assert(cp != NULL);
00506 strcpy(cp, szTargetTarfile);
00507 argv[argc++] = cp;
00508
00509 cp = alloca( strlen(szSourceName) + 1 );
00510 g_assert(cp != NULL);
00511 strcpy(cp, szSourceName);
00512 argv[argc++] = cp;
00513
00514 argv[argc] = NULL;
00515 g_assert( argc < (sizeof(argv)/sizeof(argv[0])) );
00516 rc = fork_exec(argc, argv);
00517 if (rc == 0)
00518 {
00519 sync();
00520 }
00521 else
00522 {
00523 CL_ERRORPRINTF( "Cannot create tarfile [%s] - error [%d] [%s]",
00524 szTargetTarfile, rc, strerror(rc) );
00525 (void)unlink(szTargetTarfile);
00526 (void)rmdir(szTargetContainer);
00527 (void)rename(szSourceManifestOld, szSourceManifest);
00528 return NULL;
00529 }
00530
00531
00532 rc = iliad_create_signature(szTargetTarfile, szTargetSignature);
00533 if (rc == ERR_SUCCESS)
00534 {
00535 rc = iliad_verify_signature(szTargetTarfile, szTargetSignature);
00536 }
00537 if (rc != ERR_SUCCESS)
00538 {
00539 CL_ERRORPRINTF( "Cannot sign, iliad_create_signature returns [%d] on [%s]", rc, szTargetSignature);
00540 (void)unlink(szTargetSignature);
00541 (void)unlink(szTargetTarfile);
00542 (void)rmdir(szTargetContainer);
00543 (void)rename(szSourceManifestOld, szSourceManifest);
00544 return NULL;
00545 }
00546
00547
00548
00549 argc = 0;
00550 argv[argc++] = "cp";
00551
00552 cp = alloca( strlen(szSourceManifest) + 1 );
00553 g_assert(cp != NULL);
00554 strcpy( cp, szSourceManifest);
00555 argv[argc++] = cp;
00556
00557 cp = alloca( strlen(szTargetContainer) + 1 );
00558 g_assert(cp != NULL);
00559 strcpy( cp, szTargetContainer);
00560 argv[argc++] = cp;
00561
00562 argv[argc] = NULL;
00563 g_assert( argc < (sizeof(argv)/sizeof(argv[0])) );
00564 rc = fork_exec(argc, argv);
00565 if (rc == 0)
00566 {
00567 sync();
00568
00569
00570
00571 if (RET_OK != ermXmlOpenManifest(szTargetContainer, &manifest))
00572 {
00573 CL_ERRORPRINTF("Cannot open manifest file in [%s]", szTargetContainer);
00574 }
00575 else
00576 {
00577 if (RET_OK == ermXmlExist(&manifest, XMLNODE_STARTPAGE))
00578 {
00579 ermXmlRemoveNode(&manifest, XMLNODE_STARTPAGE);
00580 }
00581
00582 rc = ermXmlSaveAndClose(&manifest);
00583 if (rc != RET_OK)
00584 {
00585 CL_ERRORPRINTF("Cannot save manifest file in [%s]", szTargetContainer);
00586 }
00587 }
00588 }
00589 else
00590 {
00591 CL_ERRORPRINTF( "Cannot copy [%s] to [%s] - error [%d] [%s]",
00592 szSourceManifest, szTargetContainer, rc, strerror(rc) );
00593 }
00594
00595
00596 return strdup(szTargetContainer);
00597 }
00598
00599
00600
00601 static void ctrl_sign_pincode_ok()
00602 {
00603 CL_CONTROLPRINTF("entry");
00604
00605 ContentLister* theContentLister = g_item_to_be_shared.theContentLister;
00606 g_assert(theContentLister != NULL);
00607
00608 int itemIndex = g_item_to_be_shared.index;
00609 g_assert(itemIndex >= 0 && itemIndex < theContentLister->itemCount);
00610
00611 clDisplayItem_t* theItem = theContentLister->items + itemIndex;
00612 g_assert(theItem->fit == mdsFitContainer);
00613
00614 gchar* szContainer = NULL;
00615 gchar* szSignedContainer = NULL;
00616 gchar* cp;
00617 int rc;
00618 int argc;
00619 char* argv[10];
00620
00621
00622 erbusy_blink();
00623
00624
00625 szContainer = alloca( strlen(theItem->szManifest) + 1 );
00626 g_assert(szContainer != NULL);
00627 strcpy(szContainer, theItem->szManifest);
00628 cp = strrchr(szContainer, '/');
00629 g_return_if_fail(cp != NULL);
00630 *cp = '\0';
00631
00632
00633 szSignedContainer = ctrl_sign_container(szContainer);
00634 if (szSignedContainer)
00635 {
00636
00637 ctrl_send_to_outbox(szSignedContainer, TRUE);
00638 free(szSignedContainer);
00639
00640
00641 if (g_item_to_be_shared.do_move)
00642 {
00643
00644 argc = 0;
00645 argv[argc++] = "rm";
00646 argv[argc++] = "-rf";
00647
00648 cp = alloca( strlen(szContainer) + 1 );
00649 g_assert(cp != NULL);
00650 strcpy(cp, szContainer);
00651 argv[argc++] = cp;
00652
00653 argv[argc] = NULL;
00654 g_assert( argc < (sizeof(argv)/sizeof(argv[0])) );
00655 rc = fork_exec(argc, argv);
00656 if (rc != 0)
00657 {
00658 CL_ERRORPRINTF( "Cannot remove container [%s] - error [%d] [%s]",
00659 szContainer, rc, strerror(rc) );
00660 }
00661 }
00662 }
00663 else
00664 {
00665 CL_ERRORPRINTF("Failed to sign container [%s]", szContainer);
00666 }
00667
00668
00669 g_item_to_be_shared.index = -1;
00670
00671
00672 ctrl_rescan_current();
00673 }
00674
00675
00676 static void ctrl_sign_pincode_quit()
00677 {
00678 CL_CONTROLPRINTF("entry");
00679
00680
00681 g_item_to_be_shared.index = -1;
00682
00683
00684 ctrl_rescan_current();
00685 }
00686
00687
00688
00689 static gboolean ctrl_show_sel_list_wnd(int itemIndex, ContentLister* theContentLister)
00690 {
00691 CL_CONTROLPRINTF("entry");
00692
00693 g_assert(theContentLister != NULL);
00694 g_assert(itemIndex >= 0 && itemIndex < theContentLister->itemCount);
00695 clDisplayItem_t* theItem = theContentLister->items + itemIndex;
00696
00697 gboolean found_list_to_display = FALSE;
00698
00699 int i;
00700 int sel_num;
00701 int sel_idx;
00702 int item_num;
00703 int item_idx;
00704
00705 const gchar** item_tbl = NULL;
00706 const mdsSelection_t* selection = NULL;
00707 const mdsSelectionItem_t* item = NULL;
00708 erGtkSelectionGroup* sel_group = NULL;
00709 GtkToggleButton* button = NULL;
00710 GtkWidget* list_item = NULL;;
00711
00712
00713 if (getListerState() == STATE_MISC)
00714 {
00715
00716 CL_ERRORPRINTF("getListerState returns STATE_MISC");
00717 return FALSE;
00718 }
00719 if (g_selectionList)
00720 {
00721 CL_ERRORPRINTF("g_selectionList present [%p]", g_selectionList);
00722 return FALSE;
00723 }
00724
00725 setListerState(STATE_MISC);
00726 erbusy_blink();
00727
00728
00729 g_selectionList = erClXmlFetchSelectionList(theItem->szManifest);
00730 g_assert(g_selectionList != NULL);
00731 CL_LOGPRINTF("erClXmlFetchSelectionList returns [%d] items", g_selectionList->num_selections);
00732
00733
00734 erClXmlGetSelectionListItemState(g_selectionList, SELECTION_TRANSFER_MODE, ITEM_TRANSFER_MOVE, &g_item_to_be_shared.do_move);
00735 erClXmlGetSelectionListItemState(g_selectionList, SELECTION_DOCUMENT_SIGNING, ITEM_SIGN_YES, &g_item_to_be_shared.do_sign);
00736
00737
00738 display_update_increase_level(LISTER_EXPOSE_LEVEL);
00739
00740
00741 sel_num = g_selectionList->num_selections;
00742 selection = g_selectionList->selections;
00743
00744 g_selection_groups = g_new0(erGtkSelectionGroup*, sel_num + 2);
00745 g_assert(g_selection_groups);
00746
00747 for (sel_idx = 0 ; sel_idx < sel_num ; sel_idx++, selection++)
00748 {
00749 if (selection->hide == FALSE)
00750 {
00751 found_list_to_display = TRUE;
00752
00753
00754 item_num = selection->num_items;
00755 item_tbl = alloca((item_num + 1) * sizeof(gchar*));
00756 item = selection->items;
00757 for (item_idx = 0 ; item_idx < item_num ; item_idx++, item++)
00758 {
00759 item_tbl[item_idx] = item->name;
00760 }
00761 item_tbl[item_idx] = NULL;
00762
00763
00764 sel_group = dist_list_wnd_add_list( selection->display_as,
00765 selection->title,
00766 selection->instruction,
00767 item_tbl );
00768 g_selection_groups[sel_idx] = sel_group;
00769
00770
00771
00772 item = selection->items;
00773 for (item_idx = 0 ; item_idx < item_num ; item_idx++, item++)
00774 {
00775 if (item->state)
00776 {
00777 button = ergtk_selection_group_get_button(sel_group, item_idx);
00778 if (button)
00779 {
00780 gtk_toggle_button_set_active(button, TRUE);
00781 }
00782 }
00783 }
00784
00785
00786 if (selection->constant)
00787 {
00788 ergtk_selection_group_freeze_buttons(sel_group, TRUE);
00789 }
00790 else
00791 {
00792 ergtk_selection_group_set_details( sel_group, selection->min_selected, selection->max_selected);
00793 }
00794 }
00795 }
00796
00797 item_tbl = alloca(sizeof(gchar*));
00798 item_tbl[0] = NULL;
00799 sel_group = dist_list_wnd_add_list("default", "", _("Click the 'Share' icon to add this document to your outbox."), item_tbl);
00800 ergtk_selection_list_show_titlebar(ERGTK_SELECTION_LIST(sel_group), FALSE);
00801
00802 dist_list_wnd_goto_page(1);
00803
00804
00805 for (i = 0 ; i < MAX_ITEMS_ON_ONE_PAGE ; i++)
00806 {
00807 if (i != itemIndex)
00808 {
00809 list_item = lsGetListerItem(theContentLister->lister, i);
00810 gtk_widget_hide(list_item);
00811 }
00812 }
00813 gtk_widget_show(theContentLister->distListWnd);
00814
00815 return found_list_to_display;
00816 }
00817
00818
00819 void ctrl_hide_sel_list_wnd(ContentLister* theContentLister, gboolean bSave)
00820 {
00821 CL_CONTROLPRINTF("entry bSave[%d]", bSave);
00822
00823 const mdsSelection_t* selection = NULL;
00824 erGtkSelectionGroup* sel_group;
00825
00826 int sel_num;
00827 int sel_idx;
00828 int item_num;
00829 int item_idx;
00830
00831 int button_idx;
00832 gint* button_ids = NULL;
00833 gboolean* button_states = NULL;
00834
00835
00836 if ( (getListerState() == STATE_MISC)
00837 && (theContentLister->distListWnd)
00838 && GTK_WIDGET_VISIBLE(theContentLister->distListWnd) )
00839 {
00840
00841 if (bSave && g_selectionList && g_selection_groups)
00842 {
00843 sel_num = g_selectionList->num_selections;
00844 selection = g_selectionList->selections;
00845 for (sel_idx = 0 ; sel_idx < sel_num ; sel_idx++, selection++)
00846 {
00847 item_num = selection->num_items;
00848 sel_group = g_selection_groups[sel_idx];
00849
00850
00851 if (selection->constant == FALSE && sel_group)
00852 {
00853 button_ids = alloca(item_num * sizeof(gint) );
00854 button_states = alloca(item_num * sizeof(gboolean));
00855 g_assert(button_ids != NULL);
00856 g_assert(button_states != NULL);
00857 ergtk_selection_group_get_selected_buttons(ERGTK_SELECTION_GROUP(sel_group), button_ids, item_num);
00858
00859
00860
00861
00862 for (item_idx = 0 ; item_idx < item_num ; item_idx++)
00863 {
00864 button_states[item_idx] = FALSE;
00865 }
00866
00867 for (button_idx = 0 ; button_idx < item_num ; button_idx++)
00868 {
00869 item_idx = button_ids[button_idx];
00870 if (item_idx >= 0 && item_idx < item_num)
00871 {
00872 button_states[item_idx] = TRUE;
00873 }
00874 }
00875
00876 for (item_idx = 0 ; item_idx < item_num ; item_idx++)
00877 {
00878 erClXmlSetSelectionItem(g_selectionList, sel_idx, item_idx, button_states[item_idx]);
00879 }
00880 }
00881 }
00882
00883
00884 erClXmlSaveSelectionList(g_selectionList);
00885 }
00886
00887
00888 erClXmlGetSelectionListItemState(g_selectionList, SELECTION_TRANSFER_MODE, ITEM_TRANSFER_MOVE, &g_item_to_be_shared.do_move);
00889 erClXmlGetSelectionListItemState(g_selectionList, SELECTION_DOCUMENT_SIGNING, ITEM_SIGN_YES, &g_item_to_be_shared.do_sign);
00890
00891
00892 dist_list_wnd_clear();
00893 gtk_widget_hide(theContentLister->distListWnd);
00894
00895
00896 ctrl_rescan_current();
00897
00898
00899 gtk_widget_show(theContentLister->listerArea);
00900 gtk_widget_grab_focus(theContentLister->listerArea);
00901 setListerState(STATE_NORMAL);
00902 }
00903
00904
00905 erClXmlFreeSelectionList(g_selectionList);
00906 g_selectionList = NULL;
00907
00908
00909 g_free(g_selection_groups);
00910 g_selection_groups = NULL;
00911
00912 CL_CONTROLPRINTF("leave");
00913 }
00914