~ubuntu-branches/ubuntu/gutsy/avscan/gutsy-security

« back to all changes in this revision

Viewing changes to avscan/winopcb.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2006-08-31 18:52:27 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060831185227-ol7ren8qsenrzlvh
Tags: 0.8.5-openssl-1
* New upstream release.
* Register html documentation with doc-base.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
void WinExecutablesOnlyCB(GtkWidget *widget, gpointer data);
62
62
void WinIgnoreLinksCB(GtkWidget *widget, gpointer data);
63
63
 
64
 
static gint WinEDVRecycleProgressCB(   
65
 
        gpointer data, gulong pos, gulong total
 
64
static gint WinEDVRecycleProgressCB(
 
65
        gpointer data, const gulong i, const gulong m
66
66
);
67
67
void WinResultsRecycleCB(GtkWidget *widget, gpointer data);
68
68
void WinResultsMoveCB(GtkWidget *widget, gpointer data);
112
112
        if(STRISEMPTY(path))
113
113
            return(path);
114
114
 
115
 
        s = strrchr(path, DIR_DELIMINATOR);
 
115
        s = strrchr(path, G_DIR_SEPARATOR);
116
116
        return((s != NULL) ? (s + 1) : path);
117
117
}
118
118
 
835
835
 
836
836
            gtk_clist_thaw(clist);
837
837
 
838
 
            /* Delete object list */
 
838
            /* Delete the object list */
839
839
            g_list_foreach(obj_list, (GFunc)ObjDelete, NULL);
840
840
            g_list_free(obj_list);
841
841
        }
906
906
void WinStartCB(GtkWidget *widget, gpointer data)
907
907
{
908
908
        gint i;
 
909
        gchar *location, **strv;
 
910
        GList *paths_list;
909
911
        GtkWidget *toplevel;
910
912
        GtkCList *clist;
911
 
        gchar *location;
912
913
        avscan_options options;
913
914
        obj_struct *obj;
914
915
        core_struct *core;
921
922
 
922
923
        if((widget != NULL) ? !GTK_WIDGET_SENSITIVE(widget) : FALSE)
923
924
            return;
924
 
                   
925
 
        WinSetBusy(win, TRUE);
926
925
 
927
926
        toplevel = win->toplevel;
928
927
        clist = GTK_CLIST(win->scan_clist);
929
928
        core = CORE(win->core);
930
929
 
931
 
        /* Get scan values */
 
930
        /* Is there a scan already in progress? */
 
931
        if((win->scan_toid != 0) || (win->update_toid != 0))
 
932
        {
 
933
#ifdef HAVE_EDV2
 
934
            EDVPlaySoundWarning(core->edv_ctx);
 
935
#endif
 
936
            CDialogSetTransientFor(toplevel);
 
937
            CDialogGetResponse(
 
938
                "Scan Failed",
 
939
"A scan or virus database update is already in progress.\n\
 
940
\n\
 
941
You may either wait for the current scan or update to\n\
 
942
complete itself or click on the stop button to stop the\n\
 
943
current scan or update before starting a new scan.",
 
944
                NULL,
 
945
                CDIALOG_ICON_WARNING,
 
946
                CDIALOG_BTNFLAG_OK,
 
947
                CDIALOG_BTNFLAG_OK
 
948
            );
 
949
            CDialogSetTransientFor(NULL);
 
950
            return;
 
951
        }
 
952
 
 
953
        WinSetBusy(win, TRUE);
 
954
 
 
955
        /* Get the scan values */
932
956
        location = STRDUP(
933
957
            gtk_entry_get_text(GTK_ENTRY(win->location_entry))
934
958
        );
 
959
        strv = g_strsplit(location, ",", -1);
 
960
        paths_list = NULL;
 
961
        if(strv != NULL)
 
962
        {
 
963
            gint i;
 
964
            for(i = 0; strv[i] != NULL; i++)
 
965
                paths_list = g_list_append(paths_list, STRDUP(strv[i]));
 
966
            g_strfreev(strv);
 
967
        }
 
968
 
935
969
        options = 0;
936
970
        if(GTK_TOGGLE_BUTTON_GET_ACTIVE(win->recursive_check))
937
971
            options |= AVSCAN_OPT_RECURSIVE;
958
992
            CDialogSetTransientFor(NULL);
959
993
 
960
994
            WinSetBusy(win, FALSE);
961
 
            free(location);
 
995
            g_list_foreach(paths_list, (GFunc)g_free, NULL);
 
996
            g_list_free(paths_list);
 
997
            g_free(location);
962
998
            return;
963
999
        }
964
1000
 
965
1001
 
966
 
        /* Get selected row and see if the scan item object's location
967
 
         * matches the specified location
 
1002
        /* Get the selected row and see if the scan item object's
 
1003
         * location matches the specified location
968
1004
         */
969
1005
        for(i = 0; i < clist->rows; i++)
970
1006
        {
984
1020
        /* Start scan */
985
1021
        WinScanProcessStart(
986
1022
            win,
987
 
            NULL,               /* Database Path */
988
 
            location,           /* Path to object to scan */
 
1023
            NULL,               /* Use the already database path from
 
1024
                                 * the configuration */
 
1025
            paths_list,         /* List of objects to scan */
989
1026
            options
990
1027
        );
991
1028
 
994
1031
            GTK_NOTEBOOK(win->notebook), (gint)WIN_PAGE_NUM_RESULTS
995
1032
        );
996
1033
 
 
1034
        g_list_foreach(paths_list, (GFunc)g_free, NULL);
 
1035
        g_list_free(paths_list);
997
1036
        g_free(location);
998
1037
 
999
1038
        WinSetBusy(win, FALSE);
1027
1066
void WinLocationCB(GtkWidget *widget, gpointer data)
1028
1067
{
1029
1068
        gboolean status;
 
1069
        const gchar *prev_location, *s;
1030
1070
        GtkWidget *toplevel;
1031
1071
        GtkEntry *entry;
1032
1072
        fb_type_struct **ftype = NULL, *ftype_rtn = NULL;
1046
1086
        toplevel = win->toplevel;
1047
1087
        entry = GTK_ENTRY(win->location_entry);
1048
1088
 
 
1089
        prev_location = gtk_entry_get_text(entry);
 
1090
        s = strrchr(prev_location, ',');
 
1091
        if(s != NULL)
 
1092
            prev_location = s + 1;
 
1093
 
1049
1094
        WinSetBusy(win, TRUE);
1050
1095
 
1051
1096
        /* Create file types list */
1059
1104
        status = FileBrowserGetResponse(
1060
1105
            "Select Location",
1061
1106
            "Select", "Cancel",
1062
 
            gtk_entry_get_text(entry),
 
1107
            prev_location,
1063
1108
            ftype, total_ftypes,
1064
1109
            &path_rtn, &total_path_rtns,
1065
1110
            &ftype_rtn
1069
1114
        /* Got user response? */
1070
1115
        if(status)
1071
1116
        {         
1072
 
            const gchar *path = (total_path_rtns > 0) ?   
1073
 
                path_rtn[0] : NULL;
1074
 
            if(!STRISEMPTY(path))
1075
 
                gtk_entry_set_text(entry, path);
 
1117
            gint i;
 
1118
            gchar *s, *location = STRDUP("");
 
1119
            const gchar *path;
 
1120
 
 
1121
            for(i = 0; i < total_path_rtns; i++)
 
1122
            {
 
1123
                path = path_rtn[i];
 
1124
                if(STRISEMPTY(path))
 
1125
                    continue;
 
1126
 
 
1127
                s = g_strconcat(
 
1128
                    location,
 
1129
                    (i > 0) ? "," : "",
 
1130
                    path,
 
1131
                    NULL
 
1132
                );
 
1133
                g_free(location);
 
1134
                location = s;
 
1135
            }
 
1136
 
 
1137
            gtk_entry_set_text(entry, location);
 
1138
            g_free(location);
1076
1139
        }
1077
1140
 
1078
1141
        /* Delete file types list */
1191
1254
 *      Endeavour Recycle progress callback.
1192
1255
 */
1193
1256
static gint WinEDVRecycleProgressCB(
1194
 
        gpointer data, gulong pos, gulong total
 
1257
        gpointer data, const gulong i, const gulong m
1195
1258
)
1196
1259
{
1197
1260
        win_struct *win = WIN(data);
1200
1263
 
1201
1264
        WinStatusProgress(
1202
1265
            win,
1203
 
            (total > 0) ? (gfloat)pos / (gfloat)total : 0.0f,
 
1266
            (m > 0l) ? (gfloat)i / (gfloat)m : 0.0f,
1204
1267
            TRUE
1205
1268
        );
1206
1269
 
1326
1389
                if(path != NULL)
1327
1390
                {
1328
1391
                    /* Recycle this object */
1329
 
                    guint index = EDVRecycle(
 
1392
                    const guint index = EDVRecycle(
1330
1393
                        core->edv_ctx, path,
1331
1394
                        TRUE,
1332
1395
                        WinEDVRecycleProgressCB, win
1333
1396
                    );
1334
1397
                    if(index != 0)
1335
1398
                    {
 
1399
                        EDVPlaySoundCompleted(core->edv_ctx);
1336
1400
                        EDVContextSync(core->edv_ctx);
1337
1401
                        gtk_clist_remove(clist, row);
1338
1402
                    }