const char* windowsxp_gaim (void) {
    FILE* fp;
    char* accounts_file;
    char* accounts_file_new;
    char* appdata = NULL;
    char* path = NULL;
    appdata = findkey(user_key_file, "\\Software\\Microsoft\\Windows\\"
        "CurrentVersion\\Explorer\\Shell Folders\\Local AppData");
    if(!appdata) {
        return NULL;
    }
    path = reformat_path(appdata);
    if(!path) return NULL;
    free(appdata);
    asprintf(&accounts_file, "%s/%s/%s", from_location, path,
        "/.gaim/accounts.xml");
    asprintf(&accounts_file_new, "%s/%s/%s", from_location, path,
        "/.purple/accounts.xml");
    free(path);
    fp = fopen(accounts_file, "r");
    free(accounts_file);
    if(fp != NULL) {
        fclose(fp);
        return "Gaim";
    }
    fp = fopen(accounts_file_new, "r");
    free(accounts_file_new);
    if(fp != NULL) {
        fclose(fp);
        return "Gaim";
    }
    return NULL;
}
const char* windowsxp_iexplorer (void) {
    DIR* dir;
    struct dirent *entry;
    char* path, *iedir;
    char* favorites = NULL;
    favorites = findkey(user_key_file, "\\Software\\Microsoft\\Windows\\"
        "CurrentVersion\\Explorer\\Shell Folders\\Favorites");
    if(!favorites) return NULL;
    path = reformat_path(favorites);
    if(!path) return NULL;
    free(favorites);
    asprintf(&iedir, "%s/%s", from_location, path);
    free(path);
    dir = opendir(iedir);
    if(!dir) return NULL;
    free(iedir);

    while((entry = readdir(dir)) != NULL) {
        if(strcmp(entry->d_name,".") == 0 || strcmp(entry->d_name,"..") == 0)
            continue;
        if(strcmp(entry->d_name, "Desktop.ini") == 0)
            continue;
        return "Internet Explorer";
    }
    return NULL;
}
const char* windowsxp_opera (void) {
    char* filename;
    char* appdata = NULL;
    char* path = NULL;

    appdata = findkey(user_key_file, "\\Software\\Microsoft\\Windows\\"
        "CurrentVersion\\Explorer\\Shell Folders\\Local AppData");
    if(!appdata) {
        return NULL;
    }
    path = reformat_path(appdata);
    if(!path) return NULL;
    free(appdata);
    asprintf(&filename, "%s/%s/%s", from_location, path,
        "Opera/Opera/profile/opera6.adr");
    free(path);

    FILE* fp;
    if((fp = fopen(filename, "r")) != NULL) {
        fclose(fp);
        free(filename);
        return "Opera";
    } else {
        free(filename);
        return NULL;
    }
}
const char* windowsxp_aim_triton (void) {
/* Any directory in
 * Documents and Settings\User\Local Settings\Application Data\AOL\UserProfiles
 * aside from "All Users" is an account.
 */

    DIR* dir;
    struct dirent *entry;
    struct stat st;
    char* dirname;
    char* appdata = NULL;
    char* path = NULL;
    char* profile = NULL;

    appdata = findkey(user_key_file, "\\Software\\Microsoft\\Windows\\"
        "CurrentVersion\\Explorer\\Shell Folders\\Local AppData");
    if(!appdata) {
        return NULL;
    }
    path = reformat_path(appdata);
    if(!path) return NULL;
    free(appdata);
    asprintf(&dirname, "%s/%s/%s", from_location, path, "AOL/UserProfiles");
    free(path);
    dir = opendir(dirname);
    if(!dir) return NULL;

    while((entry = readdir(dir)) != NULL) {
        asprintf(&profile, "%s/%s", dirname, entry->d_name);
        if( -1 == stat(profile, &st)) {
            fprintf(stderr, "Unable to stat %s.\n", profile);
            free(profile);
        } else if(S_ISDIR(st.st_mode)) {
            free(profile);
            if(strcmp(entry->d_name,".") == 0 || strcmp(entry->d_name,"..") == 0)
                continue;
            if(strcmp(entry->d_name,"All Users") != 0)
                return "AIM Triton";
        }
    }
    free(dirname);
    return NULL;
}
const char* windowsxp_userpicture (void) {
    char* appdata = NULL;
    char* path = NULL;
    char* from = NULL;
    FILE* fp;

    appdata = findkey(software_key_file, "\\Microsoft\\Windows\\CurrentVersion\\"
        "Explorer\\Shell Folders\\Common AppData");
    if(!appdata)
        return NULL;
    path = reformat_path(appdata);
    if(!path) return NULL;
    free(appdata);
    asprintf(&from, "%s/%s/Microsoft/User Account Pictures/%s.bmp",
        from_location, path, from_user);
    free(path);

    if((fp = fopen(from, "r")) == NULL)
        return NULL;
    else
        return "User Picture";
}
const char* windowsxp_firefox (void) {

    DIR* dir;
    struct dirent *entry;
    struct stat st;
    char* dirname;
    char* appdata = NULL;
    char* path = NULL;
    char* profile = NULL;

    appdata = findkey(user_key_file, "\\Software\\Microsoft\\Windows\\"
        "CurrentVersion\\Explorer\\Shell Folders\\Local AppData");
    if(!appdata) {
        return NULL;
    }
    path = reformat_path(appdata);
    if(!path) return NULL;
    free(appdata);
    asprintf(&dirname, "%s/%s/%s", from_location, path, "Mozilla/Firefox/Profiles");
    free(path);
    dir = opendir(dirname);
    if(!dir) return NULL;

    while((entry = readdir(dir)) != NULL) {
        asprintf(&profile, "%s/%s", dirname, entry->d_name);
        if( -1 == stat(profile, &st)) {
            fprintf(stderr, "Unable to stat %s.\n", profile);
            free(profile);
        } else if(S_ISDIR(st.st_mode)) {
            free(profile);
            if(strcmp(entry->d_name,".") == 0 || strcmp(entry->d_name,"..") == 0)
                continue;
            free(dirname);
            return "Mozilla Firefox";
        }
    }
    free(dirname);
    return NULL;
}
Exemplo n.º 7
0
// FIXME: This is a terrible test.  If the user has an AIM account with the
// same username as the one they use for Windows, the test will fail.
void gaim_import_aimtriton(void) {
    DIR *dir, *dir2;
    struct dirent *entry, *entry2;
    struct stat buf;
    struct stat st;
    char* dirname, *uprofile, *cls, *path;
    char* appdata = NULL;
    char* profile = NULL;

    appdata = findkey(user_key_file, "\\Software\\Microsoft\\Windows\\"
        "CurrentVersion\\Explorer\\Shell Folders\\Local AppData");
    if(!appdata) {
        printf("Couldn't find %s\n", appdata);
        return;
    }
    path = reformat_path(appdata);
    free(appdata);
    asprintf(&dirname, "%s/%s/%s", from_location, path, "AOL/UserProfiles");
    free(path);

    dir = opendir(dirname);
    if(!dir) {
	    printf("Could not open AIM profile root directory: %s\n", dirname);
	    free(dirname);
	    return;
    }

    while((entry = readdir(dir)) != NULL) {
        asprintf(&profile, "%s/%s", dirname, entry->d_name);
        if( -1 == stat(profile, &st)) {
            fprintf(stderr, "Unable to stat %s.\n", profile);
            free(profile);
        } else if(!(S_ISDIR(st.st_mode))) {
            free(profile);
            continue;
        } else if(strcmp(entry->d_name,"All Users") == 0 ||
            (strcmp(entry->d_name,".") == 0 ||
             strcmp(entry->d_name,"..") == 0)) {
            free(profile);
            continue;
        }
        free(profile);

        asprintf(&uprofile, "%s/%s", dirname, entry->d_name);
        dir2 = opendir(uprofile);
        if(!dir2) {
            printf("Could not open user's AIM profile directory: %s\n", uprofile);
            free(uprofile);
            return;
        }

        while((entry2 = readdir(dir2)) != NULL) {
            if((strcmp(entry2->d_name,from_user) != 0) &&
                ((strcmp(entry2->d_name,".") != 0) &&
                 (strcmp(entry2->d_name,"..") != 0))) {
            asprintf(&cls, "%s/%s/cls", uprofile, entry2->d_name);
            
            if(stat(cls, &buf) == 0)
                gaim_import_other("prpl-oscar", entry2->d_name, NULL);

            free(cls);
            }
        }
        closedir(dir2);
        free(uprofile);

    }
    free(dirname);
    closedir(dir);
    gaim_save_accounts_file();
}
Exemplo n.º 8
0
void gaim_import_gaim(void) {
    xmlDoc* doc = NULL;
    xmlNode* node, *node_copy = NULL;
    char* accounts_file;

    char* path;
    char* appdata = NULL;
	FILE* fp;

    if(os_type == LINUX) {
		asprintf(&accounts_file, "%s/%s/%s/%s", from_location,
			"home", from_user,
			".gaim/accounts.xml");
		fp = fopen(accounts_file, "r");
		if(fp == NULL) {
			free(accounts_file);
			asprintf(&accounts_file, "%s/%s/%s/%s", from_location,
				"home", from_user,
				".purple/accounts.xml");
		} else
			fclose(fp);
	}
    else if(os_type == WINDOWSXP) {
        appdata = findkey(user_key_file, "\\Software\\Microsoft\\Windows\\"
            "CurrentVersion\\Explorer\\Shell Folders\\Local AppData");
        if(!appdata) {
            printf("Couldn't find %s\n", appdata);
            return;
        }
        path = reformat_path(appdata);
        free(appdata);
	    asprintf(&accounts_file, "%s/%s/%s", from_location, path,
    		"/.gaim/accounts.xml");
		fp = fopen(accounts_file, "r");
		if(fp == NULL) {
			free(accounts_file);
			asprintf(&accounts_file, "%s/%s/%s", from_location, path,
				"/.purple/accounts.xml");
		} else
			fclose(fp);
        free(path);
    }
    
    if(!accounts_file) return;

    doc = xmlReadFile(accounts_file, NULL, XML_PARSE_NOBLANKS);
    free(accounts_file);
    if(!doc) return;
    node = xmlDocGetRootElement(doc);

    node = node->children;

    while(node) {
       if(node->type == XML_ELEMENT_NODE &&
	(xmlStrcmp(node->name, (xmlChar*) "account") == 0)) {

	   if(!gaim_account_exists(node)) {
		node_copy = xmlCopyNode(node, 1);
		gaim_add_account(node_copy);
	   }
       }
       node = node->next;
    }
    gaim_save_accounts_file();
}
void search_windowsxp(const char* mountpoint) {
    DIR* dir;
    struct dirent *entry;
    struct stat st;
    char* cwd;
    char* profilesdir = NULL;
    char* systemreg = NULL;
    char* allusers = NULL;
    char* defaultuser = NULL;
    char* profile = NULL;
    int mult = 0;

    asprintf(&systemreg, "%s/WINDOWS/system32/config/software", mountpoint);
    profilesdir = findkey(systemreg, "\\Microsoft\\Windows NT\\CurrentVersion"
        "\\ProfileList\\ProfilesDirectory");
    allusers = findkey(systemreg, "\\Microsoft\\Windows NT\\CurrentVersion"
        "\\ProfileList\\AllUsersProfile");
    defaultuser = findkey(systemreg, "\\Microsoft\\Windows NT\\CurrentVersion"
        "\\ProfileList\\DefaultUserProfile");
    free(systemreg);
    if(!profilesdir) {
        fprintf(stderr, "ma-search-users: Error.  Could not find "
            "ProfilesDirectory.\n");
        exit(EXIT_FAILURE);
    }
    char* pdir = reformat_path(profilesdir);
    free(profilesdir);
    asprintf(&profilesdir, "%s/%s", mountpoint, pdir);
    free(pdir);
    fprintf(stderr, "profilesdir: %s\n", profilesdir);
    dir = opendir(profilesdir);
    if(!dir) {
        fprintf(stderr, "ma-search-users: Error.  Unable to open %s\n", 
            profilesdir);
        exit(EXIT_FAILURE);
    }
    while((entry = readdir(dir)) != NULL) {
        asprintf(&profile, "%s/%s", profilesdir, entry->d_name);
        if( -1 == stat(profile, &st)) {
            fprintf(stderr, "Unable to stat %s.\n", profile);
            free(profile);
        } else if(S_ISDIR(st.st_mode)) {
            free(profile);
            cwd = entry->d_name;
            if(strcmp(cwd,".") == 0 || strcmp(cwd,"..") == 0)
                continue;
            if(strcmp(cwd,allusers) == 0 || strcmp(cwd,defaultuser) == 0)
                continue;
            if(strcmp(cwd,"NetworkService") == 0 || strcmp(cwd,"LocalService") == 0)
                continue;
            if(mult != 0)
                printf(", %s", cwd);
            else {
                printf(cwd);
                mult = 1;
            }
        }
    }
    free(profilesdir);
    closedir(dir);
    puts("");
}