Changeset 3896
- Timestamp:
- 01/21/08 13:31:52 (5 years ago)
- Location:
- trunk/src/target/OM-2007.2/applications/openmoko-dialer2
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
src/phone-kit/moko-sms.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
r3878 r3896 1 2008-01-21 Chris Lord <chris@openedhand.com> 2 3 * src/phone-kit/moko-sms.c: (moko_sms_set_property), 4 (moko_sms_dispose), (on_error), (sms_store_opened_cb), 5 (stop_handling_sms), (open_sms_store), (memory_check_idle), 6 (moko_sms_init): 7 Add monitoring of free memory on the root filesystem (hopefully) 8 1 9 2008-01-18 Chris Lord <chris@openedhand.com> 2 10 -
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-sms.c
r3863 r3896 20 20 21 21 #include <string.h> 22 #include <sys/vfs.h> 22 23 23 24 #include <dbus/dbus-glib.h> … … 77 78 78 79 gboolean sim_full; 80 gboolean memory_full; 81 82 guint memory_idle; 79 83 }; 80 84 81 85 static void start_handling_sms (MokoSms *sms); 86 static void stop_handling_sms (MokoSms *sms); 87 static void open_sms_store (MokoSms *sms); 82 88 83 89 static void … … 129 135 case PROP_NETWORK : 130 136 if (priv->network) { 131 moko_network_remove_listener (priv->network, MOKO_LISTENER (object));137 stop_handling_sms (sms); 132 138 g_object_unref (priv->network); 133 139 } … … 141 147 G_CALLBACK (subscriber_number_changed_cb), object);*/ 142 148 /* moko_network_add_listener happens in start_handling_sms */ 143 if ( !priv->handling_sms) start_handling_sms (sms);149 if ((!priv->sim_full) && (!priv->memory_full)) start_handling_sms (sms); 144 150 break; 145 151 default: … … 157 163 priv = sms->priv; 158 164 165 if (priv->memory_idle) { 166 g_source_remove (priv->memory_idle); 167 priv->memory_idle = 0; 168 } 169 159 170 while (g_source_remove_by_user_data (object)) moko_notify_stop (priv->notify); 160 171 161 172 if (priv->sms_store) { 162 173 g_object_unref (priv->sms_store); … … 428 439 if (cms == 322) { 429 440 priv->sim_full = TRUE; 430 g_signal_emit (listener, signals[MEMORY_FULL], 0, TRUE, FALSE);441 g_signal_emit (listener, signals[MEMORY_FULL], 0, TRUE, priv->memory_full); 431 442 } 432 443 } … … 579 590 priv->sms_store_open = TRUE; 580 591 592 g_debug ("Sms store opened"); 593 581 594 /* Hook onto added/modified/removed signals for SMS notification */ 582 595 view = jana_store_get_view (store); … … 592 605 593 606 static void 607 stop_handling_sms (MokoSms *sms) 608 { 609 MokoSmsPrivate *priv = sms->priv; 610 611 if (!priv->handling_sms) return; 612 613 g_debug ("Closing sms store"); 614 615 moko_network_remove_listener (priv->network, MOKO_LISTENER (sms)); 616 617 g_object_unref (priv->sms_store); 618 priv->sms_store = NULL; 619 620 priv->sms_store_open = FALSE; 621 priv->handling_sms = FALSE; 622 623 g_signal_emit (sms, signals[STATUS_CHANGED], 0, PK_SMS_NOTREADY); 624 } 625 626 static void 627 open_sms_store (MokoSms *sms) 628 { 629 MokoSmsPrivate *priv = sms->priv; 630 631 if (priv->sms_store) return; 632 633 g_debug ("Opening sms store"); 634 635 /* Get the SMS note store */ 636 priv->sms_store = jana_ecal_store_new (JANA_COMPONENT_NOTE); 637 g_signal_connect (priv->sms_store, "opened", 638 G_CALLBACK (sms_store_opened_cb), sms); 639 jana_store_open (priv->sms_store); 640 } 641 642 static gboolean 643 memory_check_idle (MokoSms *sms) 644 { 645 struct statfs buf; 646 647 MokoSmsPrivate *priv = sms->priv; 648 649 statfs ("/", &buf); 650 651 /* TODO: Is it reasonable to expect 4 megs/100 files free? */ 652 if (((buf.f_bfree * buf.f_bsize) < (1024*1024*4)) || 653 (buf.f_ffree < 100)) { 654 if (!priv->memory_full) { 655 priv->memory_full = TRUE; 656 g_signal_emit (sms, signals[MEMORY_FULL], 0, priv->sim_full, TRUE); 657 if (priv->sms_store) { 658 stop_handling_sms (sms); 659 } 660 } 661 } else if (priv->memory_full) { 662 priv->memory_full = FALSE; 663 g_signal_emit (sms, signals[MEMORY_FULL], 0, priv->sim_full, FALSE); 664 open_sms_store (sms); 665 } 666 667 return TRUE; 668 } 669 670 static void 594 671 moko_sms_init (MokoSms *sms) 595 672 { … … 603 680 priv->notify = moko_notify_get_default (); 604 681 605 /* Get the SMS note store */606 priv->sms_store = jana_ecal_store_new (JANA_COMPONENT_NOTE);607 g_signal_connect (priv->sms_store, "opened",608 G_CALLBACK (sms_store_opened_cb), sms);609 jana_store_open (priv->sms_store);682 memory_check_idle (sms); 683 if (!priv->memory_full) open_sms_store (sms); 684 685 priv->memory_idle = g_timeout_add_seconds (5, (GSourceFunc) 686 memory_check_idle, sms); 610 687 } 611 688
Note: See TracChangeset
for help on using the changeset viewer.
