/** * Free up all completion index data. */ static void free_all(void) { free_completion_list(); free_all_addresses(); g_completion_free(g_completion); g_completion = NULL; }
/** * Read address book, creating all entries in the completion index. */ static void read_address_book(gchar *folderpath) { free_all_addresses(); free_completion_list(); #ifndef USE_ALT_ADDRBOOK addrindex_load_completion( add_address, folderpath ); #else GError* error = NULL; addrcompl_initialize(); if (! addrindex_dbus_load_completion(add_address, &error)) { g_warning("Failed to populate address completion list"); g_error_free(error); return; } #endif /* plugins may hook in here to modify/extend the completion list */ if(!folderpath) { hooks_invoke(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST, &g_address_list); } g_address_list = g_list_reverse(g_address_list); g_completion_list = g_list_reverse(g_completion_list); /* merge the completion entry list into g_completion */ if (g_completion_list) { g_completion_add_items(g_completion, g_completion_list); if (debug_get_mode()) debug_print("read %d items in %s\n", g_list_length(g_completion_list), folderpath?folderpath:"(null)"); } }
boolean get_eg_file_list() { /* On exit, "completion_list" specifies a list of extant files * completion_list->identifier is the local name * completion_list->data is the full path name */ char ch, *cp; char localname[FILENAME_LEN], realname[FILENAME_LEN]; size_t cmdp; /* Collect the library name */ for (cmdp = nodebot + 2, cp = lib; (ch = info_file[cmdp]) != '\n'; cmdp++) *cp++ = ch; if (cp != lib) *cp = '\0'; free_completion_list(); /* collect the information about extant files */ for (cmdp++; info_file[cmdp] != info_separator_char; cmdp++) { for (cp = localname; ((ch = info_file[cmdp]) != '\n') && (ch != TAB) && (ch != SPACE); cmdp++) *cp++ = ch; *cp = '\0'; for ( ; info_file[cmdp] != '\n'; cmdp++ ) ; /* If filename starts with a '/', filename must exist. */ /* If lib starts with a '/', lib/filename must exist. */ /* Otherwise, libname/lib/filename must exist. */ if (FILE_EXISTS(localname)) strcpy(realname, localname); else if ((lib[0] == '/') || (libname == NULL) || (libname[0] == '\0')) (void)sprintf( realname, "%s/%s", lib, localname ); else (void)sprintf( realname, "%s/%s/%s", libname, lib, localname ); /* make sure that the library version exists */ if (FILE_EXISTS( realname )) add_completion(localname, realname); } return(completion_list != NULL); }