#include <config.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <liberregxml/erregapi.h>
#include <libergtk/ergtk.h>
#include <liberipc/eripctoolbar.h>
#include <libermanifest/ermanifest.h>
#include "contentListerLog.h"
#include "erConnect.h"
#include "system.h"
#include "gtkPincodeScreen.h"
#include "control.h"
#include "cursor.h"
#include "displayUpdate.h"
#include "erMdsContent.h"
#include "gtkDistListWnd.h"
#include "control_share.h"
#include "erbusy.h"
#include "sign.h"
#include "toolbar.h"
#include "pagebar.h"
#include "languages.h"
Go to the source code of this file.
Defines | |
#define | _GNU_SOURCE |
Enumerations | |
enum | dist_list_reason_e { dl_approve = 0, dl_reject, dl_undefined } |
Functions | |
static gboolean | ctrl_send_to_outbox (const gchar *szSourcename, const gboolean bDeleteOriginal) |
static gchar * | ctrl_sign_container (const char *szSourcename) |
static void | ctrl_sign_pincode_ok (void) |
static void | ctrl_sign_pincode_quit (void) |
static gboolean | ctrl_show_sel_list_wnd (int itemIndex, ContentLister *theContentLister) |
void | ctrl_listItem_share (const int *index_tbl, ContentLister *theContentLister) |
void | ctrl_doc_share_now (ContentLister *theContentLister) |
void | ctrl_hide_sel_list_wnd (ContentLister *theContentLister, gboolean bSave) |
Variables | |
struct { | |
int index | |
gboolean do_move | |
gboolean do_sign | |
ContentLister * theContentLister | |
} | g_item_to_be_shared |
static const mdsSelectionList_t * | g_selectionList = NULL |
static erGtkSelectionGroup ** | g_selection_groups |
#define _GNU_SOURCE |
Definition at line 35 of file control_share.c.
enum dist_list_reason_e |
Definition at line 72 of file control_share.c.
00073 { 00074 dl_approve = 0, 00075 dl_reject, 00076 dl_undefined 00077 } dist_list_reason_e;
void ctrl_doc_share_now | ( | ContentLister * | theContentLister | ) |
Definition at line 266 of file control_share.c.
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 // save selection lists, hide screen 00281 ctrl_hide_sel_list_wnd(theContentLister, TRUE); 00282 00283 // sign document, when needed 00284 if (g_item_to_be_shared.do_sign) 00285 { 00286 // show pincode screen 00287 ctrl_show_pincode_screen(signDocument_t, ctrl_sign_pincode_ok, ctrl_sign_pincode_quit); 00288 } 00289 else 00290 { 00291 // determine containername 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 // move/copy document to outbox 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 // no more signing to do 00307 g_item_to_be_shared.index = -1; 00308 } 00309 } 00310 }
void ctrl_hide_sel_list_wnd | ( | ContentLister * | theContentLister, | |
gboolean | bSave | |||
) |
Definition at line 819 of file control_share.c.
00820 { 00821 CL_CONTROLPRINTF("entry bSave[%d]", bSave); 00822 00823 const mdsSelection_t* selection = NULL; 00824 erGtkSelectionGroup* sel_group; 00825 00826 int sel_num; // number of selections 00827 int sel_idx; // selection index 00828 int item_num; // number of items 00829 int item_idx; // item index 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 // save states from selection lists 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 // update XML item states from button states 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 // set item state 00860 // Note: button_ids[] sorted chronologically, NOT on button_id value 00861 // set all items to FALSE 00862 for (item_idx = 0 ; item_idx < item_num ; item_idx++) 00863 { 00864 button_states[item_idx] = FALSE; 00865 } 00866 // set selected items to TRUE 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 // update XML according to states 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 // save updated states to manifest file 00884 erClXmlSaveSelectionList(g_selectionList); 00885 } 00886 00887 // get special values from selection lists 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 // hide distribution list window 00892 dist_list_wnd_clear(); 00893 gtk_widget_hide(theContentLister->distListWnd); 00894 00895 // re-display all items 00896 ctrl_rescan_current(); 00897 00898 // show contentlister page 00899 gtk_widget_show(theContentLister->listerArea); 00900 gtk_widget_grab_focus(theContentLister->listerArea); 00901 setListerState(STATE_NORMAL); 00902 } 00903 00904 // free g_selectionList 00905 erClXmlFreeSelectionList(g_selectionList); 00906 g_selectionList = NULL; 00907 00908 // free g_selection_groups 00909 g_free(g_selection_groups); 00910 g_selection_groups = NULL; 00911 00912 CL_CONTROLPRINTF("leave"); 00913 }
void ctrl_listItem_share | ( | const int * | index_tbl, | |
ContentLister * | theContentLister | |||
) |
Definition at line 211 of file control_share.c.
00212 { 00213 gboolean ok; 00214 00215 CL_CONTROLPRINTF("entry: index [%d]", *index_tbl); 00216 g_assert(theContentLister != NULL); 00217 00218 // find out which item must be shared 00219 const int index = *index_tbl; // only one item expected 00220 g_assert(index >= 0 && index < theContentLister->itemCount); 00221 00222 // and set a pointer to the item details 00223 clDisplayItem_t* theItem = theContentLister->items + index; 00224 00225 erbusy_blink(); 00226 00227 // update the stored index value 00228 mdsSetIndex(theContentLister->currentContentType, index + ((theContentLister->currentPage - 1) * MAX_ITEMS_ON_ONE_PAGE)); 00229 00230 // remember which item we are sharing 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 // convert file to container 00237 if (theItem->fit == mdsFitFile) 00238 { 00239 ctrl_before_file_clicked(theItem); 00240 } 00241 00242 // show selection list window 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 }
static gboolean ctrl_send_to_outbox | ( | const gchar * | szSourcename, | |
const gboolean | bDeleteOriginal | |||
) | [static] |
Definition at line 104 of file control_share.c.
00105 { 00106 gboolean bRet = FALSE; // not ok (yet) 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 // find device on which this item is located 00120 device = ctrl_is_trusted_path(szSourcename); 00121 if (device == NULL) 00122 { 00123 // no device found 00124 CL_ERRORPRINTF("Item not on a trusted filesystem [%s]", szSourcename); 00125 } 00126 else 00127 { 00128 // determine target name 00129 szFilename = strrchr(szSourcename, '/'); 00130 g_return_val_if_fail((szFilename != NULL), FALSE); 00131 szFilename++; 00132 00133 // create outbox if needed 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 // check target already in outbox 00140 strcat(szTargetname, "/"); 00141 strcat(szTargetname, szFilename); 00142 // add a sequence number, in case of duplicate filenames 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 // send item to outbox 00155 if (bDeleteOriginal) 00156 { 00157 // move item to outbox 00158 rc = rename(szSourcename, szTargetname); 00159 if (rc == 0) 00160 { 00161 sync(); 00162 bRet = TRUE; // success 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 // copy item to outbox 00173 // command = cp -r <source-container> <target-container> 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; // success 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 // report success or not 00206 return bRet; 00207 }
static gboolean ctrl_show_sel_list_wnd | ( | int | itemIndex, | |
ContentLister * | theContentLister | |||
) | [static] |
Definition at line 689 of file control_share.c.
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; // return value 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 // already handling an item: ignore 00716 CL_ERRORPRINTF("getListerState returns STATE_MISC"); 00717 return FALSE; // error 00718 } 00719 if (g_selectionList) 00720 { 00721 CL_ERRORPRINTF("g_selectionList present [%p]", g_selectionList); 00722 return FALSE; // error 00723 } 00724 00725 setListerState(STATE_MISC); 00726 erbusy_blink(); 00727 00728 // read distributionlist from manifest 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 // get special values from selection lists 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 // increase level to prevent display from updating in checkBtn 00738 display_update_increase_level(LISTER_EXPOSE_LEVEL); 00739 00740 // show selection lists as read from manifest 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 // build table with item names 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 // add this selection to screen layout 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 // set buttons state 00771 // Note: default is not active, so we only set the active buttons 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 // set selectiongroup details 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 // hide not-selected lister items, then show distribution list screen 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 }
static gchar * ctrl_sign_container | ( | const char * | szSourcename | ) | [static] |
Definition at line 314 of file control_share.c.
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 // get current date-time string 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 // get derived file-/directory names 00356 // source container name 00357 szSourceName = strrchr(szSourceContainer, '/'); 00358 if (szSourceName == NULL) 00359 { 00360 CL_ERRORPRINTF("Illegal container name [%s]", szSourceContainer); 00361 return NULL; 00362 } 00363 szSourceName++; 00364 // target container name 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 // target tarfile name 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 // target signature filename 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 // remove target container, if any 00389 if (lstat(szTargetContainer, &status) == 0) 00390 { 00391 CL_WARNPRINTF("-- container already present [%s]", szTargetContainer); 00392 // command = rm -rf <target-container> 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 // update manifest file: 00414 // open manifest file 00415 if (RET_OK != ermXmlOpenManifest(szSourceContainer, &manifest)) 00416 { 00417 CL_ERRORPRINTF("Cannot open manifest file in [%s]", szSourceContainer); 00418 return NULL; 00419 } 00420 // remember source manifest filename 00421 ccp = ermXmlGetFileName(&manifest); 00422 szSourceManifest = alloca( strlen(ccp) + 1 ); 00423 g_assert(szSourceManifest != NULL); 00424 strcpy(szSourceManifest, ccp); 00425 // save original manifest file 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 // remove existing section document-signing, if any 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 // add document signing info 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 // set user's email address 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 // set iLiad's MAC address 00460 CL_CONTROLPRINTF("MAC address [%s]", get_sysset_macAddress()); 00461 ermXmlSetString(&manifest, XMLNODE_DOCUMENT_SIGNING "/iliad-mac-address", get_sysset_macAddress()); 00462 // set data-time stamp 00463 CL_CONTROLPRINTF("date [%s]", szDateTime); 00464 ermXmlSetString(&manifest, XMLNODE_DOCUMENT_SIGNING "/date", szDateTime); 00465 // save manifest file 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 // create target container 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 // combine source container into a tarball in target container 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 // command = tar -czf <target-tarfile> <source-directory-name> 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 // add and verify signature to target container 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 // add manifest file to target container 00548 // command = cp <source-manifest> <target-container> 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 // remove start-page entry from target manifest 00570 // open manifest file 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 // save manifest file 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 // report what happened 00596 return strdup(szTargetContainer); 00597 }
static void ctrl_sign_pincode_ok | ( | void | ) | [static] |
Definition at line 601 of file control_share.c.
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 // determine containername 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 // sign document 00633 szSignedContainer = ctrl_sign_container(szContainer); 00634 if (szSignedContainer) 00635 { 00636 // move signed container to outbox 00637 ctrl_send_to_outbox(szSignedContainer, TRUE); 00638 free(szSignedContainer); 00639 00640 // remove original, when needed 00641 if (g_item_to_be_shared.do_move) 00642 { 00643 // command = rm -rf <container> 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 // no more signing to do 00669 g_item_to_be_shared.index = -1; 00670 00671 // show new situation 00672 ctrl_rescan_current(); 00673 }
static void ctrl_sign_pincode_quit | ( | void | ) | [static] |
Definition at line 676 of file control_share.c.
00677 { 00678 CL_CONTROLPRINTF("entry"); 00679 00680 // no more signing to do 00681 g_item_to_be_shared.index = -1; 00682 00683 // show new situation 00684 ctrl_rescan_current(); 00685 }
gboolean do_move |
Definition at line 83 of file control_share.c.
gboolean do_sign |
Definition at line 84 of file control_share.c.
struct { ... } g_item_to_be_shared [static] |
erGtkSelectionGroup** g_selection_groups [static] |
Definition at line 89 of file control_share.c.
const mdsSelectionList_t* g_selectionList = NULL [static] |
Definition at line 88 of file control_share.c.
int index |
Definition at line 82 of file control_share.c.
Definition at line 85 of file control_share.c.