]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/install+setup/install/nic.c
Ich hab mal ein bisschen die Arbeit vom Cuebernommen :D
[people/pmueller/ipfire-2.x.git] / src / install+setup / install / nic.c
index 665e0d040612b1b40a6235c72e9ea5df5d543112..0c5c3d545e3e6ce02e2d037fe330ad81cdc541cc 100644 (file)
@@ -24,89 +24,47 @@ extern struct nic nics[];
 
 int networkmenu(struct keyvalue *ethernetkv)
 {
-       int i;
-       int count;
-       char nics;
-       char number;
-       char cbValue;
+       int rc;
        char driver[STRING_SIZE] = "";
        char driveroptions[STRING_SIZE] = "";
-       struct keyvalue *kv = initkeyvalues();
        int result = 0;
        char commandstring[STRING_SIZE];
        char address[STRING_SIZE], netmask[STRING_SIZE];
-       FILE *handle;
+       int done;
        char description[1000];
        char message[1000];
        char title[STRING_SIZE];
+       done = 0;
 
-       /* Detect and count nics */
-       count = mysystem("/bin/probenic.sh count");
-       fprintf(flog, "Number of detected nics: %s\n", count);
-
-/*     sprintf(commandstring, "/bin/probenic.sh");
-       sprintf(message, ctr[TR_PROBING_FOR_NICS]);
-       runcommandwithstatus(commandstring, message); */
-
-/*     handle = fopen("/nicdriver", "r");
-       fgets(nics, STRING_SIZE, handle);
-       fclose(handle); */
-
-/*     fprintf(flog, "Detected NIC drivers: %s\n",driver); */
-
-/*     sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN);
-       sprintf(message, ctr[TR_FOUND_NIC], NAME, description);
-       newtWinMessage(title, ctr[TR_OK], message); */
-
-       newtComponent form, checkbox, rb[count], button;
-       newtOpenWindow(10, 5, 60, 11, "Checkboxes and Radio buttons");
-
-       for (i = 1; i <= 2; i++)
+       while (!done)
        {
-               fprintf(flog, "Scan: %d\n", i);
-               snprintf(commandstring, STRING_SIZE, "/bin/probenic.sh %i", i);
-               mysystem(commandstring);
-               if ((handle = fopen("/nicdriver", "r")) == NULL) {
-                       errorbox(ctr[TR_ERROR]);
-                       goto EXIT;
-               }
-               fgets(driver, STRING_SIZE, handle);
-               fclose(handle);
-               findnicdescription(driver, description);
-               if ( i == 0 )
-                       rb[i] = newtRadiobutton(1, i+2, description, 1, NULL);
+               rc = newtWinTernary(ctr[TR_CONFIGURE_NETWORKING], ctr[TR_PROBE], 
+                       ctr[TR_SELECT], ctr[TR_CANCEL], ctr[TR_CONFIGURE_NETWORKING_LONG]);
+               
+               if (rc == 0 || rc == 1)
+               {
+                       probecards(driver, driveroptions);
+                       if (!strlen(driver))
+                               errorbox(ctr[TR_PROBE_FAILED]);
+                       else
+                       {
+                               findnicdescription(driver, description);
+                               sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
+                               sprintf(message, ctr[TR_FOUND_NIC], NAME, description);
+                               newtWinMessage(title, ctr[TR_OK], message);
+                       }               
+               }                       
+               else if (rc == 2)
+                       choosecards(driver, driveroptions);
                else
-                       rb[i] = newtRadiobutton(1, i+2, description, 0, rb[i-1]);
-       }
-       button = newtButton(1, count+3, "OK");
-
-       form = newtForm(NULL, NULL, 0);
-       newtFormAddComponent(form, checkbox);
-       for (i = 1; i <= 2; i++) {
-               fprintf(flog, "Add: %d\n", i);
-               newtFormAddComponent(form, rb[i]);
+                       done = 1;       
+                       
+               if (strlen(driver))
+                       done = 1;
        }
-       newtFormAddComponent(form, button);
-
-       newtRunForm(form);
-       newtFinished();
-
-       for (i = 1; i <= 2; i++)
-               if (newtRadioGetCurrent(rb[0]) == rb[i])
-                       printf("radio button picked: %d\n", i);
-       newtFormDestroy(form);
-
-
-/*     snprintf(commandstring, STRING_SIZE, "/bin/probenic.sh 1");
-       mysystem(commandstring);        
-       if ((handle = fopen("/nicdriver", "r")) == NULL) {
-               errorbox(ctr[TR_ERROR]);
+       
+       if (!strlen(driver))
                goto EXIT;
-       }
-       fgets(driver, STRING_SIZE, handle);
-       fprintf(flog, "Green nic driver: %s\n", driver);
-       fclose(handle); */
 
        /* Default is a GREEN nic only. */
        /* Smoothie is not untarred yet, so we have to delay actually writing the
@@ -134,8 +92,6 @@ int networkmenu(struct keyvalue *ethernetkv)
        result = 1;
        
 EXIT:
-       freekeyvalues(kv);
        
        return result;
 }
-