summaryrefslogtreecommitdiffstats
path: root/meta-openmoko/packages/openmoko2/openmoko-dialer2/openmoko-dialer.patch
blob: 5969726857a8ec63a7a6a3c50205ab25b94b3b6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
--- openmoko-dialer2/src/moko-dialer.c~	2007-08-27 20:02:37.000000000 +0930
+++ openmoko-dialer2/src/moko-dialer.c	2007-08-27 18:59:37.000000000 +0930
@@ -69,8 +69,7 @@
 
   /* Registration variables */
   guint               reg_timeout;
-  gboolean            reg_request;
-  gboolean            registered;
+  MokoGsmdConnectionNetregType registered;
 };
 
 enum
@@ -292,8 +291,7 @@
 
   moko_keypad_set_pin_mode (MOKO_KEYPAD (priv->keypad), FALSE);
     
-  priv->reg_request = TRUE;
-  priv->registered = FALSE;
+  priv->registered = MOKO_GSMD_CONNECTION_NETREG_NONE;
   priv->reg_timeout = g_timeout_add (GSM_REGISTER_TIMEOUT, 
                                      (GSourceFunc)register_network_cb, 
                                      dialer);
@@ -424,14 +422,14 @@
   g_return_if_fail (MOKO_IS_DIALER (dialer));
   priv = dialer->priv;
 
+  g_warning ("on_network_registered: type is %d\n", type);
+
   switch (type)
   {
     case MOKO_GSMD_CONNECTION_NETREG_NONE:
     case MOKO_GSMD_CONNECTION_NETREG_SEARCHING:
       /* Do nothing */
       g_print ("NetReg: Searching for network\n");
-      g_source_remove (priv->reg_timeout);
-      priv->registered = TRUE;
       break;
     case MOKO_GSMD_CONNECTION_NETREG_DENIED:
       /* This may be a pin issue*/
@@ -441,11 +439,12 @@
       g_print ("NetReg: Network registered\n");
       g_print("\tLocationAreaCode = %x\n\tCellID = %x\n", lac, cell);
       g_source_remove (priv->reg_timeout);
-      priv->registered = TRUE;
       break;
     default:
       g_warning ("Unhandled register event type = %d\n", type);
    };
+
+  priv->registered = type;
 }
 
 static void
@@ -619,28 +618,32 @@
   g_return_val_if_fail (MOKO_DIALER (dialer), TRUE);
   priv = MOKO_DIALER_GET_PRIVATE (dialer);
 
-  if (!priv->reg_request)
+  /* We check whether we've been registered yet, otherwise keep poking 
+   * gsmd
+   */
+  switch (priv->registered)
   {
-    /* We have yet to request registration, so lets do it */
-    /* FIXME: do the pin stuff */
-    g_print ("Requesting registration\n");
-    moko_gsmd_connection_network_register (priv->connection);
-  }
-  else 
-  {
-    /* We check whether we've been registered yet, otherwise keep poking 
-     * gsmd
-     */
-    if (priv->registered)
-    {
-      g_print ("Network Registered\n");
-      return FALSE;
-    }
-    else
-    {
+    case MOKO_GSMD_CONNECTION_NETREG_NONE:
+      /* We have yet to request registration, so lets do it */
+      /* FIXME: do the pin stuff */
       g_print ("Requesting registration\n");
       moko_gsmd_connection_network_register (priv->connection);
-    }
+      priv->registered = MOKO_GSMD_CONNECTION_NETREG_SEARCHING;
+      break;
+    case MOKO_GSMD_CONNECTION_NETREG_SEARCHING:
+      g_print ("Waiting for registration\n");
+      break;
+    case MOKO_GSMD_CONNECTION_NETREG_DENIED:
+      g_print ("Registration denied, retrying\n");
+      moko_gsmd_connection_network_register (priv->connection);
+      priv->registered = MOKO_GSMD_CONNECTION_NETREG_SEARCHING;
+      break;
+    case MOKO_GSMD_CONNECTION_NETREG_HOME:
+    case MOKO_GSMD_CONNECTION_NETREG_ROAMING:
+      g_print ("Network Registered\n");
+	return FALSE;
+    default:
+      g_warning ("Unhandled register event type = %d\n", priv->registered);
   }
   
   return TRUE;
@@ -754,9 +757,8 @@
 
   /* Handle network registration a few seconds after powering up the 
    * antenna*/ 
-  priv->reg_request = TRUE;
-  priv->registered = FALSE;
-  priv->reg_timeout = g_timeout_add (GSM_REGISTER_TIMEOUT, 
+  priv->registered = MOKO_GSMD_CONNECTION_NETREG_NONE;
+  priv->reg_timeout = g_timeout_add (GSM_REGISTER_TIMEOUT * 2, 
                                      (GSourceFunc)register_network_cb, 
                                      dialer);