Index: data/rhythmbox.schemas
===================================================================
RCS file: /cvs/gnome/rhythmbox/data/rhythmbox.schemas,v
retrieving revision 1.84
diff -u -r1.84 rhythmbox.schemas
--- data/rhythmbox.schemas	9 Nov 2006 11:47:34 -0000	1.84
+++ data/rhythmbox.schemas	2 Dec 2006 22:50:25 -0000
@@ -893,33 +893,33 @@
         <key>/schemas/apps/rhythmbox/plugins/magnatune/cc_number</key>
         <applyto>/apps/rhythmbox/plugins/magnatune/cc_number</applyto>
         <owner>rhythmbox</owner>
-        <type>string</type>
-        <default></default>
+        <type>int</type>
+        <default>0</default>
         <locale name="C">
-        <short>The user's credit card number.</short>
-	<long>The user's credit card number. Visa/Mastercard only.</long>
+        <short>Keyring location of the user's credit card number.</short>
+	<long>Keyring location of the user's credit card number. Visa/Mastercard only.</long>
 	</locale>
       </schema>
       <schema>
         <key>/schemas/apps/rhythmbox/plugins/magnatune/cc_month</key>
         <applyto>/apps/rhythmbox/plugins/magnatune/cc_month</applyto>
         <owner>rhythmbox</owner>
-        <type>string</type>
-        <default></default>
+        <type>int</type>
+        <default>0</default>
         <locale name="C">
-        <short>Expiry month of the user's credit card.</short>
-	<long>Expiry month of the user's credit card.</long>
+        <short>Keyring location of expiry month of the user's credit card.</short>
+	<long>Keyring location of expiry month of the user's credit card.</long>
 	</locale>
       </schema>
       <schema>
         <key>/schemas/apps/rhythmbox/plugins/magnatune/cc_year</key>
         <applyto>/apps/rhythmbox/plugins/magnatune/cc_year</applyto>
         <owner>rhythmbox</owner>
-        <type>string</type>
-        <default></default>
+        <type>int</type>
+        <default>0</default>
         <locale name="C">
-        <short>Expiry year of the user's credit card.</short>
-	<long>Expiry year of the user's credit card.</long>
+        <short>Keyring location of expiry year of the user's credit card.</short>
+	<long>Keyring location of expiry year of the user's credit card.</long>
 	</locale>
       </schema>
       <schema>
Index: plugins/magnatune/magnatune/MagnatuneSource.py
===================================================================
RCS file: /cvs/gnome/rhythmbox/plugins/magnatune/magnatune/MagnatuneSource.py,v
retrieving revision 1.5
diff -u -r1.5 MagnatuneSource.py
--- plugins/magnatune/magnatune/MagnatuneSource.py	26 Nov 2006 13:19:35 -0000	1.5
+++ plugins/magnatune/magnatune/MagnatuneSource.py	2 Dec 2006 22:50:29 -0000
@@ -4,7 +4,7 @@
 
 import gobject
 import gtk.glade
-import gnomevfs, gnome, gconf
+import gnomevfs, gnome, gconf, gnomekeyring
 import xml
 import urllib, zipfile
 
@@ -355,17 +355,22 @@
 	# internal purchasing code
 	#
 	def __purchase_album(self, sku, pay, format):
-		ccnumber = self.__client.get_string(self.__plugin.gconf_keys['ccnumber'])
-		ccyear = self.__client.get_string(self.__plugin.gconf_keys['ccyear'])
-		ccmonth = self.__client.get_string(self.__plugin.gconf_keys['ccmonth'])
-		name = self.__client.get_string(self.__plugin.gconf_keys['ccname'])
 		email = self.__client.get_string(self.__plugin.gconf_keys['email'])
-		
 		if self.__client.get_bool(self.__plugin.gconf_keys['forget']):
 			ccnumber = self.__tmp_cc
 			ccyear = self.__tmp_yy
 			ccmonth = self.__tmp_mm
 			name = self.__tmp_name
+		else:
+			keyring = gnomekeyring.get_default_keyring_sync()
+			try:
+				ccnumber = gnomekeyring.item_get_info_sync(keyring, self.__client.get_int(self.__plugin.gconf_keys['ccnumber'])).get_secret()
+				ccyear = gnomekeyring.item_get_info_sync(keyring, self.__client.get_int(self.__plugin.gconf_keys['ccyear'])).get_secret()
+				ccmonth = gnomekeyring.item_get_info_sync(keyring, self.__client.get_int(self.__plugin.gconf_keys['ccyear'])).get_secret()
+			except gnomekeyring.DeniedError:
+				print "Can't get one or more CC values."
+				return
+			name = self.__client.get_string(self.__plugin.gconf_keys['ccname'])
 
 		print "purchasing tracks:", sku, pay, format, name, email
 
Index: plugins/magnatune/magnatune/__init__.py
===================================================================
RCS file: /cvs/gnome/rhythmbox/plugins/magnatune/magnatune/__init__.py,v
retrieving revision 1.2
diff -u -r1.2 __init__.py
--- plugins/magnatune/magnatune/__init__.py	11 Nov 2006 01:08:20 -0000	1.2
+++ plugins/magnatune/magnatune/__init__.py	2 Dec 2006 22:50:29 -0000
@@ -1,7 +1,7 @@
 import rhythmdb, rb
 import gobject
 import gtk, gtk.glade
-import gconf, gnomevfs, gnome
+import gconf, gnomevfs, gnome, gnomekeyring
 
 import urllib
 import zipfile
@@ -106,6 +106,7 @@
 		self.shell = None
 	
 	def create_configure_dialog(self, dialog=None):
+		keyring = gnomekeyring.get_default_keyring_sync()
 		if dialog == None:
 			
 			def ignore_checkbox_toggled(button):
@@ -127,7 +128,17 @@
 					self.client.set_bool(self.gconf_keys['forget'], False)
 			
 			def yy_entry_changed(entry):
-				self.client.set_string(self.gconf_keys['ccyear'], entry.get_text())
+				if self.client.get_int(self.gconf_keys['ccyear']) == 0:
+					auth_token = gnomekeyring.item_create_sync(
+						keyring,
+               					gnomekeyring.ITEM_GENERIC_SECRET,
+						"Magnatune credit card expiry year",
+						dict(), entry.get_text(), False)
+					self.client.set_int(self.gconf_keys['ccyear'], auth_token)
+				else:
+					secret = gnomekeyring.item_get_info_sync(keyring, self.client.get_int(self.gconf_keys['ccyear']))
+					secret.set_secret(entry.get_text())
+					gnomekeyring.item_set_info_sync(keyring, self.client.get_int(self.gconf_keys['ccyear']), secret)
 				try:
 					mm = gladexml.get_widget("mm_entry").get_active_text()
 					if int(entry.get_text()) < (datetime.date.today().year % 100):
@@ -143,7 +154,17 @@
 					print e
 			
 			def mm_entry_changed(entry):
-				self.client.set_string(self.gconf_keys['ccmonth'], entry.get_active_text())
+				if self.client.get_int(self.gconf_keys['ccmonth']) == 0:
+					auth_token = gnomekeyring.item_create_sync(
+						keyring,
+               					gnomekeyring.ITEM_GENERIC_SECRET,
+						"Magnatune credit card expiry month",
+						dict(), entry.get_active_text(), False)
+					self.client.set_int(self.gconf_keys['ccmonth'], auth_token)
+				else:
+					secret = gnomekeyring.item_get_info_sync(keyring, self.client.get_int(self.gconf_keys['ccmonth']))
+					secret.set_secret(entry.get_active_text())
+					gnomekeyring.item_set_info_sync(keyring, self.client.get_int(self.gconf_keys['ccmonth']), secret)
 				try:
 					yy = gladexml.get_widget("yy_entry").get_text()
 					if int(yy) < (datetime.date.today().year % 100):
@@ -158,10 +179,23 @@
 				except Exception,e:
 					print e
 			
+			def cc_entry_changed(entry):
+				if self.client.get_int(self.gconf_keys['ccnumber']) == 0:
+					auth_token = gnomekeyring.item_create_sync(
+						keyring,
+               					gnomekeyring.ITEM_GENERIC_SECRET,
+						"Magnatune credit card number",
+						dict(), entry.get_text(), False)
+					self.client.set_int(self.gconf_keys['ccnumber'], auth_token)
+				else:
+					secret = gnomekeyring.item_get_info_sync(keyring, self.client.get_int(self.gconf_keys['ccnumber']))
+					secret.set_secret(entry.get_text())
+					gnomekeyring.item_set_info_sync(keyring, self.client.get_int(self.gconf_keys['ccnumber']), secret)
+			
 			self.configure_callback_dic = {
 				"rb_magnatune_name_entry_changed_cb" : lambda w: self.client.set_string(self.gconf_keys['ccname'], w.get_text()),
 				"rb_magnatune_email_entry_changed_cb" : lambda w: self.client.set_string(self.gconf_keys['email'], w.get_text()),
-				"rb_magnatune_cc_entry_changed_cb" : lambda w: self.client.set_string(self.gconf_keys['ccnumber'], w.get_text()),
+				"rb_magnatune_cc_entry_changed_cb" : cc_entry_changed,
 				"rb_magnatune_yy_entry_changed_cb" : yy_entry_changed,
 				"rb_magnatune_mm_entry_changed_cb" : mm_entry_changed,
 				"rb_magnatune_pay_combobox_changed_cb" : lambda w: self.client.set_int(self.gconf_keys['pay'], w.get_active() + 5),
@@ -178,9 +212,22 @@
 			
 			gladexml.get_widget("name_entry").set_text(self.client.get_string(self.gconf_keys['ccname']))
 			gladexml.get_widget("email_entry").set_text(self.client.get_string(self.gconf_keys['email']))
-			gladexml.get_widget("cc_entry").set_text(self.client.get_string(self.gconf_keys['ccnumber']))
-			gladexml.get_widget("yy_entry").set_text(self.client.get_string(self.gconf_keys['ccyear']))
-			gladexml.get_widget("mm_entry").set_active(int(self.client.get_string(self.gconf_keys['ccmonth'])) - 1)
+			
+			try:
+				gladexml.get_widget("cc_entry").set_text(gnomekeyring.item_get_info_sync(keyring, self.client.get_int(self.gconf_keys['ccnumber'])).get_secret())
+			except gnomekeyring.DeniedError:
+				gladexml.get_widget("cc_entry").set_text("")
+			
+			try:
+				gladexml.get_widget("yy_entry").set_text(gnomekeyring.item_get_info_sync(keyring, self.client.get_int(self.gconf_keys['ccyear'])).get_secret())
+			except gnomekeyring.DeniedError:
+				gladexml.get_widget("yy_entry").set_text("")
+			
+			try:
+				gladexml.get_widget("mm_entry").set_active(int(gnomekeyring.item_get_info_sync(keyring, self.client.get_int(self.gconf_keys['ccmonth'])).get_secret()) - 1)
+			except gnomekeyring.DeniedError:
+				gladexml.get_widget("mm_entry").set_active(0)
+			
 			gladexml.get_widget("pay_combobox").set_active(self.client.get_int(self.gconf_keys['pay']) - 5)
 			gladexml.get_widget("audio_combobox").set_active(self.format_list.index(self.client.get_string(self.gconf_keys['format'])))
 			gladexml.get_widget("ignore_cc_info_checkbox").set_active(self.client.get_bool(self.gconf_keys['forget']))
