~smaioli/azureus/ubuntu-experimental

« back to all changes in this revision

Viewing changes to com/aelitis/azureus/core/subs/impl/SubscriptionHistoryImpl.java

MergedĀ VuzeĀ 4.2.0.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
import org.gudy.azureus2.core3.util.SystemTime;
33
33
 
34
34
import com.aelitis.azureus.core.AzureusCoreFactory;
 
35
import com.aelitis.azureus.core.metasearch.Engine;
35
36
import com.aelitis.azureus.core.subs.SubscriptionHistory;
36
37
import com.aelitis.azureus.core.subs.SubscriptionResult;
37
38
 
54
55
        private boolean                 auth_failed;
55
56
        private int                             consec_fails;
56
57
        
57
 
 
 
58
        private boolean                 auto_dl_supported;
 
59
        
 
60
        private boolean                 dl_with_ref     = true;
 
61
        
58
62
        protected
59
63
        SubscriptionHistoryImpl(
60
64
                SubscriptionManagerImpl         _manager,
68
72
        
69
73
        protected SubscriptionResultImpl[]
70
74
        reconcileResults(
 
75
                Engine                                                  engine,
71
76
                SubscriptionResultImpl[]                latest_results )
72
77
        {
 
78
                auto_dl_supported       = engine.getAutoDownloadSupported() == Engine.AUTO_DL_SUPPORTED_YES;
 
79
                
73
80
                int     new_unread      = 0;
74
81
                int new_read    = 0;
75
82
                                        
828
835
                num_unread      = new_unread;
829
836
        }
830
837
        
 
838
        protected boolean
 
839
        isAutoDownloadSupported()
 
840
        {
 
841
                return( auto_dl_supported );
 
842
        }
 
843
        
831
844
        protected void
832
845
        setLastError(
833
846
                String          _last_error,
866
879
                return( consec_fails );
867
880
        }
868
881
        
 
882
        public boolean
 
883
        getDownloadWithReferer()
 
884
        {
 
885
                return( dl_with_ref );
 
886
        }
 
887
        
 
888
        public void
 
889
        setDownloadWithReferer(
 
890
                boolean         b )
 
891
        {
 
892
                if ( b != dl_with_ref ){
 
893
                        
 
894
                        dl_with_ref = b;
 
895
                        
 
896
                        saveConfig();
 
897
                }
 
898
        }
 
899
        
869
900
        protected void
870
901
        loadConfig()
871
902
        {
876
907
                
877
908
                Long    l_auto_dl       = (Long)map.get( "auto_dl" );           
878
909
                auto_dl                         = l_auto_dl==null?false:l_auto_dl.longValue()==1;
879
 
 
 
910
                
880
911
                Long    l_last_scan = (Long)map.get( "last_scan" );             
881
912
                last_scan                       = l_last_scan==null?0:l_last_scan.longValue();
882
913
                
888
919
 
889
920
                Long    l_num_read      = (Long)map.get( "num_read" );          
890
921
                num_read                        = l_num_read==null?0:l_num_read.intValue();
 
922
                
 
923
                        // migration - if we've already downloaded this feed then we default to being
 
924
                        // enabled
 
925
                
 
926
                Long    l_auto_dl_s     = (Long)map.get( "auto_dl_supported" );         
 
927
                auto_dl_supported       = l_auto_dl_s==null?(last_scan>0):l_auto_dl_s.longValue()==1;
 
928
 
 
929
                Long    l_dl_with_ref   = (Long)map.get( "dl_with_ref" );               
 
930
                dl_with_ref     = l_dl_with_ref==null?true:l_dl_with_ref.longValue()==1;
 
931
 
891
932
        }
892
933
        
893
934
        protected void
897
938
                
898
939
                map.put( "enabled", new Long( enabled?1:0 ));
899
940
                map.put( "auto_dl", new Long( auto_dl?1:0 ));
 
941
                map.put( "auto_dl_supported", new Long( auto_dl_supported?1:0));
900
942
                map.put( "last_scan", new Long( last_scan ));
901
943
                map.put( "last_new", new Long( last_new_result ));
902
944
                map.put( "num_unread", new Long( num_unread ));
903
945
                map.put( "num_read", new Long( num_read ));
904
 
                
 
946
                map.put( "dl_with_ref", new Long( dl_with_ref?1:0 ));
 
947
 
905
948
                subs.updateHistoryConfig( map );
906
949
        }
907
950